NSImage/NSBitmapImageRep color shifts when creating scaled copy
NSImage/NSBitmapImageRep color shifts when creating scaled copy
- Subject: NSImage/NSBitmapImageRep color shifts when creating scaled copy
- From: Steve Christensen <email@hidden>
- Date: Fri, 06 Mar 2009 11:21:51 -0800
I'm trying to create a scaled-down copy of a large NSBitmapImageRep
(i.e., 3200x2400 -> 320x240). The smaller image eventually gets
passed to OpenGL for drawing. What I'm finding is that the copy has
color shifted. When I draw the copy, it appears to be darker and more
saturated than the original.
I have tried several ways to get a copy that has the same color
characteristics as the original but no success so far. My simplest
version looks like this:
NSRect resizedBounds = {NSZeroPoint, desiredBitmapSize};
NSImage* resizedImage = [[[NSImage alloc]
initWithSize:resizedBounds.size] autorelease];
[resizedImage lockFocus];
[[NSGraphicsContext currentContext]
setImageInterpolation:NSImageInterpolationHigh];
[image drawInRect:resizedBounds fromRect:NSZeroRect
operation:NSCompositeCopy fraction:1.0];
[resizedImage unlockFocus];
bitmapImage = [NSBitmapImageRep imageRepWithData:[resizedImage
TIFFRepresentation]];
Am I missing something or is this just how Quartz works? Is there
another way to get there? I'm not wedded to NSImage and friends if a
better solution exists elsewhere. This needs to run on 10.4 or later.
Thanks,
steve
_______________________________________________
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