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

Re: NSimage NSImageInterpolationHigh-Low not working?


  • Subject: Re: NSimage NSImageInterpolationHigh-Low not working?
  • From: Jim McKinnon <email@hidden>
  • Date: Sun, 24 Feb 2008 13:34:57 -0800

Some more information:

After more research, what I need is true bilinear interpolation to my image, which setImageInterpolation is not doing. It turns out if you read the image in TIFF into Preview, the "Adjust size" menu pick uses what seems to be the default NSImage interpolation scheme. If the base image is saved as a PDF, and opened in Preview, it then DOES use bilinear interpolation as you resize the view larger, in real time. It is very fast as well. This is what I want my App to do.

Code lines modifying ImageApp's "ImageView.m" to actually work would help the most for me, if that is possible.


On Feb 23, 2008, at 6:06 PM, Jim McKinnon wrote:

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


_______________________________________________

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


References: 
 >NSimage NSImageInterpolationHigh-Low not working? (From: Jim McKinnon <email@hidden>)

  • Prev by Date: Re: Clearing an NSTextView
  • Next by Date: Re: NSOutlineView autosaving of expanded/collapsed state
  • Previous by thread: NSimage NSImageInterpolationHigh-Low not working?
  • Next by thread: disowning a bundle?
  • Index(es):
    • Date
    • Thread