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 (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to