Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Mattias Malm  
#1 Posted : Monday, June 12, 2006 9:46:49 PM(UTC)
Mattias Malm

Rank: Member

Groups: Member
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

Dmitry  
#2 Posted : Tuesday, June 13, 2006 6:57:38 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
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

Sincerely yours, Dmitry Sevostyanov UserPostedImage Follow Aurigma on Twitter!
Mattias Malm  
#3 Posted : Tuesday, June 13, 2006 9:56:55 PM(UTC)
Mattias Malm

Rank: Member

Groups: Member
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.
Dmitry  
#4 Posted : Wednesday, June 14, 2006 7:28:39 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
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

Sincerely yours, Dmitry Sevostyanov UserPostedImage Follow Aurigma on Twitter!
Users browsing this topic
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.