• 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
NSimage NSImageInterpolationHigh-Low not working?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSimage NSImageInterpolationHigh-Low not working?


  • Subject: NSimage NSImageInterpolationHigh-Low not working?
  • From: Jim McKinnon <email@hidden>
  • Date: Sat, 23 Feb 2008 18:06:57 -0800

I have read many of the posts on this, and I ended up using this code:

NSSize theNewSize = {width*scaleFactor, height*scaleFactor};
NSImage *resizedImage = [[NSImage alloc] initWithSize: theNewSize];
[resizedImage lockFocus];
[NSGraphicsContext saveGraphicsState];
[[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh];
[image drawInRect:NSMakeRect(0.0,0.0,theNewSize.width, theNewSize.height) fromRect:NSMakeRect(0.0,0.0,[image size].width, [image size].height) operation:NSCompositeCopy fraction:1.0];
[NSGraphicsContext restoreGraphicsState];


It has a very poor interpolation, whether I use NSImageInterpolationHigh, Low, or no call at all. "None" does cause the image to not interpolate, as expected.

I am drawing to an offscreen bitmap, and using:

	[image addRepresentation:offscreenRep];

prior to these calls.

In contrast, if the Java app call below is used, the image looks great:

g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);

Since this Java code runs well on my Mac (Leopard), I assume Java uses low level system calls mapped to its functions. I would expect NSImage to be similar in quality.

I am new to Obj C, so I apologize if I am missing something here.

I am thinking something is wrong with the call since Preview does no better job scaling than my Cocoa code does.

Also, ImageApp code example also has a similar call, and setting the quality high or low again has no effect.

http://developer.apple.com/samplecode/ImageApp/index.html

Here is a link to a forum that has the images in comparison:

http://episteme.arstechnica.com/eve/forums?a=tpc&s=50009562&f=6330927813&m=430008360931&r=430008360931#430008360931

If it will work better, how do I call the interpolation correctly?

Thanks in advance for any help!
_______________________________________________

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 NSImageInterpolationHigh-Low not working?
      • From: Jim McKinnon <email@hidden>
  • Prev by Date: Re: synchronize the content of two arrays with binding
  • Next by Date: disowning a bundle?
  • Previous by thread: Re: trouble closing windows
  • Next by thread: Re: NSimage NSImageInterpolationHigh-Low not working?
  • Index(es):
    • Date
    • Thread