Here's a simple method for resizing. I made it a category of NSImage.

- (NSImage *)resizedImageForSize:(NSSize)size
{
  NSImage    *resizedImage = [[[NSImage alloc] initWithSize:size] autorelease];

  [resizedImage lockFocus];
  [self drawInRect:[resizedImage bounds] fromRect:[self bounds] 
operation:NSCompositeSourceOver fraction:1.0];
  [resizedImage unlockFocus];

  return    resizedImage;
}





--- On Thu, 12/11/08, Glenn Bloom <grb...@gmail.com> wrote:

> From: Glenn Bloom <grb...@gmail.com>
> Subject: Resizing an image
> To: cocoa-dev@lists.apple.com
> Date: Thursday, December 11, 2008, 5:43 AM
> 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.
> 
> thanks in advance for any help,
> 
> Glenn
> _______________________________________________
> 
> 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/howlewere%40yahoo.com
> 
> This email sent to howlew...@yahoo.com


      
_______________________________________________

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