Working in Visual Studio 2008. I'm trying to draw on a PNG image and save that 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 the solution gives no errors. When I try to run it, I get this:
A Graphics object cannot be created from an image that has an indexed pixel format.
I don't have much experience with using images in C#. What does this mean and how can I remedy this?
EDIT: through debugging, Visual Studio tells me that the image has a format8bppindexed
Pixel Format.
So if I can't use the Graphics class, what do I use?
EDIT2: After reading this, I think it's safe to assume that I better stick to JPG files when working with GDI+, no?
EDIT3: my using-statements:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;