Re: NSImage display quality and zooming
Re: NSImage display quality and zooming
- Subject: Re: NSImage display quality and zooming
- From: Graham Cox <email@hidden>
- Date: Wed, 28 May 2008 10:58:28 +1000
I'm not 100% on this, but I think you need to set the cache mode on
the NSImage to disable caching, i.e:
[image setCacheMode: NSImageCacheNever];
hth,
G.
On 28 May 2008, at 10:37 am, also wrote:
I've created a custom NSView that displays an image and allows the
user to zoom in and out. The view works in general, but the quality
of the image displayed is not what I expect. When I zoom in even
slightly on a high resolution image (300 dpi, 500x500) the image is
grainy and pixelated. If I do the same in Preview the quality is much
better.
I read in the image (a JPEG) using:
image = [[NSImage alloc] initWithContentsOfURL:url];
I keep a scale factor called imageScale (default 1.0) and draw the
image as follows :
[[NSGraphicsContext currentContext] setImageInterpolation:
NSImageInterpolationHigh];
NSSize viewSize = [self bounds].size;
NSSize imageSize = [image size];
NSAffineTransform* at = [NSAffineTransform transform];
[at scaleBy:imageScale];
imageSize = [at transformSize:imageSize];
NSPoint viewCenter;
viewCenter.x = viewSize.width * 0.50;
viewCenter.y = viewSize.height * 0.50;
NSPoint imageOrigin = viewCenter;
imageOrigin.x -= imageSize.width * 0.50;
imageOrigin.y -= imageSize.height * 0.50;
NSRect destRect;
destRect.origin = imageOrigin;
destRect.size = imageSize;
[image drawInRect:destRect
fromRect:NSZeroRect
operation:NSCompositeSourceOver
fraction:1.0];
I've tried adjusting the NSScale by hand rather than using the
transform, no change. I also tried subclassing an IKImageView. Using
its built in zoom worked ok but I can't draw NSBezierPaths over the
top which I also need for this subclass. Can anyone see what I'm
doing wrong, or suggest a better method?
Thanks,
-Matthew
_______________________________________________
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