I am trying to create a white picture (greyscale format).
So here is the code I use:
Bitmap bmp = new Bitmap(1, 1,
System.Drawing.Imaging.PixelFormat.Format16bppGrayScale);
bmp.SetPixel(0, 0, Color.FromArgb(255, 255, 255));
bmp = new Bitmap(bmp, i.Width, i.Height);
"I" is an existing Bitmap image. I am playing with its channels. The principle is to create a 1 pixel image in greyscale, give this pixel the white color and then enlarge it to the good size.
But I have this as a result:
"An unhandled exception of type 'System.ArgumentException' occurred in System.Drawing.dll"
I tried Color.White
but it isn't allowed for greyscale or indexed formats.
What are my other options to fix this?
Why not to do it without converting to greyscale?
Simply done by placing colour channels in the desired order
I'll post all the code. It's currently ugly I know but it's for a quick need. I am converting normal maps from the usual purple format to the orange format. It's just channels swapping.
I am using the AForge framework to do this more easily. I extract needed channels (only the red to swap) from the input pictures. I clone it, that adds an alpha channel too to the RGB entry. Then I modify the channels of the copy to get the new image.
The problem is for the red and blue channels that need new pitch white and pitch black images.
I need to create an image either in "Format8bppIndexed" (which would be nice) or at worse in "Format16bppGrayScale". SetPixel doesn't accept indexed format.