Aurigma Forums
»
Graphics Mill
»
Discussions – Graphics Mill
»
ColorProfile disappears when using DiscardAlpha()
Rank: Member
Groups: Guest
Joined: 5/4/2006(UTC) Posts: 17
|
Since JPEG images don't support alpha channel, and simply saving an image with alpha as JPEG results in a blend to black, I would like to use DiscardAlpha() to blend the image to white before saving it as JPEG. The blending works great, but every time i use DiscardAlpha() the ColorProfile property is set to NULL and the JPEG file doesn't have the assigned profile embedded. Is there a reason for this, is it a bug or am I doing something wrong? Sample code (c#): Code:// Open image
Bitmap gmImage = new Bitmap(Server.MapPath("RgbFileWithAlpha.psd"));
// Turn color management on
gmImage.ColorManagement.ColorManagementEnabled = true;
// Set transformation intent
gmImage.ColorManagement.TransformationIntent = Aurigma.GraphicsMill.Transforms.ColorTransformationIntent.Perceptual;
// Set default ICC profile if it's not embedded
if (gmImage.ColorProfile == null && gmImage.IsRgb)
gmImage.ColorProfile = new ColorProfile(Server.MapPath("ColorProfiles/sRGB IEC61966-21.icm"));
// Set destination ICC profile and convert
gmImage.ColorManagement.RgbColorProfile = new ColorProfile(Server.MapPath("Adobe RGB (1998).icm"));
gmImage.ColorManagement.ConvertToContinuous(ColorSpace.Rgb, gmImage.HasAlpha, false);
// Save file in correct format
if (gmImage.HasAlpha)
gmImage.Channels.DiscardAlpha(Aurigma.GraphicsMill.Color.FromRgb(255, 255, 255));
gmImage.Save(Server.MapPath("NewFile.jpg"), new JpegEncoderOptions(90, false));
// Clean up
gmImage.Dispose();
Edited by user Wednesday, December 19, 2007 4:18:43 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 8/3/2003(UTC) Posts: 1,070
Thanks: 1 times Was thanked: 12 time(s) in 12 post(s)
|
Hello, We confirm the problem - thanks for report. This problem will be resolved in the next version of Graphics Mill for .NET. At this moment you can use the following workaround: Code:Aurigma.GraphicsMill.ColorProfile profile = bmp.ColorProfile;
bmp.Channels.DiscardAlpha();
bmp.ColorProfile = profile;
Edited by user Wednesday, December 19, 2007 4:18:56 PM(UTC)
| Reason: Not specified |
|
|
|
|
Rank: Member
Groups: Guest
Joined: 5/4/2006(UTC) Posts: 17
|
Thanks for the confirmation. I've already tried solving the problem the way you suggested, but it seems that DiscardAlpha() releases all profile resources, including the . I get this error message: Unable to open color profile 'C:\WINDOWS\TEMP\ICM13B0.tmp'. I assign the original profile to the image from disk after using DiscardAlpha(), so the resulting file is correct now.
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 8/3/2003(UTC) Posts: 1,070
Thanks: 1 times Was thanked: 12 time(s) in 12 post(s)
|
Sorry, here is correct workaround: Code:Aurigma.GraphicsMill.ColorProfile profile = bmp.ColorProfile != null ? new Aurigma.GraphicsMill.ColorProfile(bmp.ColorProfile.FileName) : null;
bmp.Channels.DiscardAlpha();
bmp.ColorProfile = profile;
Edited by user Wednesday, December 19, 2007 4:19:11 PM(UTC)
| Reason: Not specified |
|
|
|
|
Aurigma Forums
»
Graphics Mill
»
Discussions – Graphics Mill
»
ColorProfile disappears when using DiscardAlpha()
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.