Reputation: 18802
I have a tool which manipulates images at runtime as part of my web app.
This generally works fine, but with the release of Firefox 3.5 we're seeing some colour problems. I believe this is because Firefox 3.5 now supports embedded ICC colour profiles where no other browsers do.
In order to achieve consistency of display, I'd like to programatically remove any ICC colour profile in my .NET code.
Can anyone point me in the right direction?
Thanks, - Chris
Upvotes: 1
Views: 1233
Reputation: 18802
On further investigation, it appears that IE was taking notice of some Gamma correction information, and FireFox 3.5 was taking notice of an embedded ICC colour profile.
All of this information appears to have been added by the .NET framework's PNG implementation by default.
It is possible to remove this information in .NET - I've blogged about it here.
Upvotes: 1
Reputation: 75296
This method may work (I have not tested it), although it may be overkill:
public void StripBitmap(string path)
{
Bitmap originalBitmap = (Bitmap)Bitmap.FromFile(path);
Bitmap strippedBitmap =
new Bitmap(originalBitmap.Width, originalBitmap.Height);
using (Graphics g = Graphics.FromImage(strippedBitmap))
{
g.DrawImage(originalBitmap, 0, 0);
}
System.Drawing.Imaging.ImageFormat fmt = originalBitmap.RawFormat;
originalBitmap.Dispose();
System.IO.File.Delete(path);
strippedBitmap.Save(path, fmt);
strippedBitmap.Dispose();
}
The Bitmap class in GDI+ does not appear to support color profiles, but if it does support them, I don't think they would be carried over by the DrawImage operation in the above sample.
Upvotes: 0