views:

653

answers:

1

I have an image that I get and attempt to load into a graphics object using Graphics.FromImage(image), however this throws an exception if the image has an indexed pixel format.

Is there a way to safely convert an indexed image?

Update: Thanks to Joe for the tip to just draw the old image over the new one, instead I was trying to convert it. This makes a lot of sense.

+3  A: 

One easy way is to create a new image of the same size (with a 32-bit pixel format). Then create a graphics object for that image and draw the original on top of it.

Joseph