Tag Archives: images

Scaling an image in Objective-C (Cocoa Framework)

The UIImage class can be used to represent an image. The following snippet scales an image according to a size which is provided with a CGSize parameter. + (UIImage *)scale:(UIImage *)image toSize:(CGSize)size { UIGraphicsBeginImageContext(size); [image drawInRect:CGRectMake(0, 0, size.width, size.height)]; UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return scaledImage; }

Posted in Objective-C | Also tagged , , , , , , , , , , | Leave a comment