Skip to content

Instantly share code, notes, and snippets.

@vl4dimir
Created May 8, 2010 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vl4dimir/394778 to your computer and use it in GitHub Desktop.
Save vl4dimir/394778 to your computer and use it in GitHub Desktop.
#import "UIImage+Resizing.h"
@implementation UIImage (Resizing)
/**
* Creates a resized, autoreleased copy of the image, with the given dimensions.
* @return an autoreleased, resized copy of the image
*/
- (UIImage*) resizedImageWithSize:(CGSize)size
{
UIGraphicsBeginImageContext(size);
[self drawInRect:CGRectMake(0.0f, 0.0f, size.width, size.height)];
// An autoreleased image
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment