Exception : "A Graphics object cannot be created from an image that has an indexed pixel format".
this exception happed in my application while trying to draw string on a .gif image,
I read about this problem and found in MSDN that: If the image has an indexed pixel format, this method throws an exception with the message, "A Graphics object cannot be created from an image that has an indexed pixel format." The indexed pixel formats are shown in the following list.
Bitmap bm = (Bitmap) System.Drawing.Image.FromFile(<span class="str">"Fci-h.jpg"</span>,<span class="kwrd">true</span>);
Bitmap tmp=<span class="kwrd">new</span> Bitmap (bm.Width ,bm.Height );
And its simply worked, just create a temp Bitmap and use it to create the Graphics.
Strange but worked!!