Aurigma Forums
»
Graphics Mill
»
Samples – Graphics Mill
»
HOWTO: Load Embedded sRGB Color Profile from Image
Rank: Advanced Member
Groups: Guest
Joined: 3/9/2008(UTC) Posts: 554
Was thanked: 1 time(s) in 1 post(s)
|
Sometimes Graphics Mill users encounter a problem – when Graphics Mill loads some images created with Adobe Photoshop (or other software), color profile is not recognized by Graphics Mill, although Photoshop does display it. It happens with sRGB color profile. The reason for it is that Photoshop does not actually embeds sRGB color profiles to the image. It just sets specific EXIF field to mark the image to have sRGB color space. I guess that Adobe developers optimize output image file size this way – since sRGB color profile is always the same and available on every computer, they do not embed this profile to the file. The workaround for this problem is to check whether the image file contains this EXIF field and whether it equals to sRGB. Here is a code sample which demonstrates how to do it. This is a function which takes the file name of the image to get color profile from. Draw attention that it does not load bitmap into the memory at all. Code:static private Aurigma.GraphicsMill.ColorProfile GetColorProfile(string filename)
{
using (Aurigma.GraphicsMill.Codecs.IFormatReader reader = Aurigma.GraphicsMill.Codecs.FormatManager.CreateFormatReader(filename))
{
reader.Open(filename);
if (reader.FrameCount > 0)
{
Aurigma.GraphicsMill.Codecs.IFrame frame = reader.LoadFrame(0);
try
{
if (frame.ColorProfile != null)
{
return frame.ColorProfile;
}
else
{
Aurigma.GraphicsMill.Codecs.IMetadataReadSupport metadata = reader as Aurigma.GraphicsMill.Codecs.IMetadataReadSupport;
if (metadata!=null && metadata.Exif!=null)
{
long colorSpaceKey = Aurigma.GraphicsMill.Codecs.ExifDictionary.ColorSpace;
if (metadata.Exif.Contains(colorSpaceKey) && (int)metadata.Exif[colorSpaceKey] == 1)
{
return Aurigma.GraphicsMill.ColorProfile.FromSrgb();
}
}
}
}
catch(Aurigma.GraphicsMill.Exception)
{
}
}
}
return null;
}
Edited by moderator 13 years ago
| Reason: Not specified |
|
|
|
|
Aurigma Forums
»
Graphics Mill
»
Samples – Graphics Mill
»
HOWTO: Load Embedded sRGB Color Profile from Image
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.