I use this code to resize an image on an iPhone:
CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:kCGBlendModePlusDarker alpha:1]; UIImage *tmpValue = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
Works great if the aspect ratio of the image matches the image format with the new resized. I would like to change this so that it maintains the correct aspect ratio and simply places the black background anywhere where the image does not appear. Thus, I still get a 320x480 image, but with black top and bottom or sides depending on the size of the original image.
Is there an easy way to do this similar to what I'm doing? Thank!
ios iphone core-graphics uiimage
Cory Imdieke Nov 09 '09 at 19:13 2009-11-09 19:13
source share