• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSImage display quality and zooming
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSImage display quality and zooming
      • From: Michael Vannorsdel <email@hidden>
    • Re: NSImage display quality and zooming
      • From: also <email@hidden>
References: 
 >NSImage display quality and zooming (From: also <email@hidden>)

  • Prev by Date: NSImage display quality and zooming
  • Next by Date: Re: NSImage display quality and zooming
  • Previous by thread: NSImage display quality and zooming
  • Next by thread: Re: NSImage display quality and zooming
  • Index(es):
    • Date
    • Thread