Search code examples
c#image.net-4.0system.drawing

Why would the output image from this code be darker than the original?


I'm a newbie to working with images in NET. My goal is to add text and an icon to the starting image, then save the output.

The result comes out a bit darker. Starting with a solid image (png-24) #788eb3 comes out #6d84ab. Tested to insure background/transparency is not the issue.

I removed everything except the code to get the image, then save it, and the result is still darker. What direction should I go to make this work better?

System.Drawing.Image img = Bitmap.FromFile(@"c:\\oldfile.png", true);
img.Save(@"c:\\newfile.png", ImageFormat.Png);

Solution

  • The real issue turned out to be the browser! IE7 and IE8 render #788eb3 in a png differently than the same color as a css background color. IE9, Chrome and Firefox all look good.