Steve, thank you - I just tested your recommendation - it appears to work
well.  Doug, I just got your recommendation and will look into CICrop and
CILanczosScaleTransform, and CGImageRef documentation on creating images of
a particular size.  I'm in fact about to run out to a Cocoaheads meeting, so
will get back to this in the AM maybe with more thoughts as well and will
post again.  Thank you both.

On Thu, Dec 11, 2008 at 2:44 PM, Steve Christensen <puns...@mac.com> wrote:

> On Dec 11, 2008, at 5:43 AM, Glenn Bloom wrote:
>
> Can anyone recommend a best practice for resizing an image to reduce its
>> size in terms of both bytes and visible dimensions, retaining the new
>> smaller image and eliminating the original from memory?  In how I go about
>> this now, I am concerned about memory and efficiency.
>>
>
> How about something like this?
>
> NSImage* oldImage = GetSomeImage(...);
> NSSize   newSize = GetDesiredNewSize(oldImage, ...);
>
> NSImage* newImage = [[NSImage alloc] initWithSize:newSize];
>
> [newImage lockFocus];
> [oldImage drawInRect:NSMakeRect(0, 0, newSize.width, newSize.height)
>        fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0];
> [newImage unlockFocus];
>
> [oldImage release];
>
>
> And depending on how important the resized image quality is, you may also
> want to do the following just before the drawInRect call:
>
> [[NSGraphicsContext currentContext]
> setImageInterpolation:NSImageInterpolationHigh];
>
>
_______________________________________________

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 arch...@mail-archive.com

Reply via email to