views:

360

answers:

2

Hi,

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

A: 

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.

MusiGenesis
Thanks for the reply, but my code is doing this sort of thing already. Unfortunately I don't know enough about colour profiles to know where the problem is. For all I know it might be a *lack* of colour profile that's causing FireFox 3.5 to render the colours differently?!
Chris Roberts
@Chris: that sounds plausible. Can you post some pictures or something that show what the color problems are, exactly?
MusiGenesis
By the way, I think most people know that "color" == "colour". We're just saving up our excess vowels to be shipped to the Balkans. :)
MusiGenesis
Yeah - I know everyone knows the difference in the spelling - just making it easier for the search engines!
Chris Roberts
+1  A: 

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.

Chris Roberts