Re: NSImage ignoring interpolation: Is this a bug?
Re: NSImage ignoring interpolation: Is this a bug?
- Subject: Re: NSImage ignoring interpolation: Is this a bug?
- From: Mark Onyschuk <email@hidden>
- Date: Sat, 25 Nov 2006 16:16:14 -0500
On 24-Nov-06, at 9:15 PM, Scott Stevenson wrote:
Playing around with NSImage I noticed that it's pretty brutal to
scaling bitmap images. It looks like it's ignoring the
interpolation setting on the context.
This draws the images in a relatively pixelated manner:
[[NSGraphicsContext currentContext]
setImageInterpolation: NSImageInterpolationHigh];
NSSize size = { 256, 160 };
float center = [self bounds].size.width * 0.50;
float middle = [self bounds].size.height * 0.50;
NSPoint origin = { center - size.width * 0.50, middle +
size.height * 0.5 };
NSString * path = @"/Library/Desktop Pictures/Aqua Blue.jpg";
NSImage * image = [[NSImage alloc] initByReferencingFile:path];
[image setScalesWhenResized:YES];
[image setSize: size];
[image compositeToPoint:origin operation:NSCompositeSourceOver];
[image release];
Just a thought, the -[NSImage compositeToPoint:operation:] is a
method from back in the NeXTstep days and has some behaviors that are
meant to be compatible with code from the days of Display Postscript.
You might find that the -drawInRect:fromRect:operation:fraction:
method (that's new in Mac OS X and Quartz) behaves better for you.
-Mark
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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