Work in Visual Studio 2008. I am trying to draw a PNG image and save this image again.
I do the following:
private Image img = Image.FromFile("file.png"); private Graphics newGraphics;
And in the constructor:
newGraphics = Graphics.FromImage(img);
Building a solution does not make mistakes. When I try to run it, I get the following:
Unable to create graphic from image with indexed pixel format.
I don't have much experience using images in C #. What does this mean and how can I fix it?
EDIT: Through debugging, Visual Studio tells me that the image has a format8bppindexed Pixel format.
So, if I cannot use the Graphics class, what am I using?
EDIT2: after reading this , I'm sure I'm sure it is better to use JPG files when working with GDI +, no?
EDIT3: my service statements:
using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using System.Windows.Forms;
c # image png graphics
Kdgdev
source share