FROM : Jim McKinnon
DATE : Sun Feb 24 22:34:57 2008
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_removed>)
>
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
>
DATE : Sun Feb 24 22:34:57 2008
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_removed>)
>
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
>
| Related mails | Author | Date |
|---|---|---|
| Jim McKinnon | Feb 24, 03:06 | |
| Jim McKinnon | Feb 24, 22:34 |






Cocoa mail archive

