Re: Converting NSImage to cmtk yeilds green images
Re: Converting NSImage to cmtk yeilds green images
- Subject: Re: Converting NSImage to cmtk yeilds green images
- From: Ken Ferry <email@hidden>
- Date: Sat, 15 Jan 2011 12:58:41 -0800
Hi Ken,
You may want to ask on the colorsync-users mailing list as well as give
sample before/after images. My quick test produced some degradation, but
not more than I would expect. I'm not sure if you're seeing something else
or if you expect the RGB->CMYK->RGB (when it goes back to the screen) round
trip to be less lossy than it is.
I have some comments, but most likely they aren't enough for you.
(1) Why are you using device vs calibrated? You should almost never use
device color spaces.
(2) You need to bracket the setCurrentContext: with +[NSGraphicsContext
save/restoreGraphicsState]. You are leaving the current context pointing at
your bitmap here. In addition, the context that was previously current may
be deallocated.
(3) The NSImage methods that start with -composite are deprecated.
(4) FYI,
-[NSBitmapImageRep bitmapImageRepByConvertingToColorSpace:renderingIntent:]
exists.
-Ken
Cocoa Frameworks
On Fri, Jan 14, 2011 at 2:06 PM, Ken Tozier <email@hidden> wrote:
> Hi
>
> I'm trying to write an NSImage category that converts an image to cmyk . It
> sort of works, in that it does produce a new image, but all images have a
> dark green cast to them and look sort of solarized or like negatives. Anyone
> point out what I'm doing wrong?
>
> Thanks for any help
>
> - (NSImage *) cmykImage
> {
> NSImage *result = [[NSImage alloc]
> initWithSize: [self size]];
>
> NSBitmapImageRep *rep = [[NSBitmapImageRep
> alloc]
>
> initWithBitmapDataPlanes: NULL
>
> pixelsWide: [self size].width
>
> pixelsHigh: [self size].height
>
> bitsPerSample: 8
>
> samplesPerPixel: 4
>
> hasAlpha: NO
>
> isPlanar: NO
>
> colorSpaceName: NSDeviceCMYKColorSpace
>
> bytesPerRow: 0
>
> bitsPerPixel: 0];
>
> NSGraphicsContext *context = [NSGraphicsContext
> graphicsContextWithBitmapImageRep: rep];
>
> [NSGraphicsContext setCurrentContext: context];
>
> [context setImageInterpolation: NSImageInterpolationHigh];
>
> [self compositeToPoint: NSZeroPoint operation:
> NSCompositeSourceOver];
>
> [result addRepresentation: rep];
>
> return result;
> }_______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden