This is my bitmap creation code
public static Bitmap Plot24(ref byte[] bufferArray, int lengthOfBufferArray, String fileName)
{
int position = 0;
int rows = (int)Math.Ceiling((double)lengthOfBufferArray / (3*columns) );
Bitmap b = new Bitmap(columns , rows, PixelFormat.Format24bppRgb);
BitmapData bmd = b.LockBits(new Rectangle(0, 0, columns , rows), ImageLockMode.ReadWrite, b.PixelFormat);
unsafe
{
for (int j = 0; j < rows; j++)
{
byte* row = (byte*)bmd.Scan0 + ((j * bmd.Stride) );
for (int i = 0; i < columns*3; i+=3)
{
if (position < lengthOfBufferArray)
{
try
{
row[i+2] = bufferArray[position];
position++;
if (position < lengthOfBufferArray)
{
row[i+1] = bufferArray[position];
position++;
}
else
{
break;
}
if (position < lengthOfBufferArray)
{
row[i] = bufferArray[position];
position++;
}
else
{
break;
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
}
b.UnlockBits(bmd);
return b;
}
}
And this is how i save the returned bitmap
b.Save(outputFilename, ImageFormat.Bmp);
When i have all FF hexadecimals in the bufferArray still the white pixels are not that white.
And when i have random values in the bufferArray other colors also look like they are washed away.
How can i make it save in the normal brightness level ?
I tested your sample code and it worked just fine. I have an excerpt of you sample at the bottom of mine with some slight modification to the method parameters.
Could you supply in your question a sample of how you use your Plot24 method? Maybe the problem lies there.