我的图像尺寸为1200x1200。(从服务器获取)。我可以将它减少到800x800(不使用“预览”)。由于图像尺寸较大,我的应用程序崩溃..请帮助我解决这个问题......提前谢谢。
答案 0 :(得分:11)
UIImage *image = [actualImage you want to resize];
UIImage *tempImage = nil;
CGSize targetSize = CGSizeMake(196,110);
UIGraphicsBeginImageContext(targetSize);
CGRect thumbnailRect = CGRectMake(0, 0, 0, 0);
thumbnailRect.origin = CGPointMake(0.0,0.0);
thumbnailRect.size.width = targetSize.width;
thumbnailRect.size.height = targetSize.height;
[image drawInRect:thumbnailRect];
tempImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
你可以使用这个tempImage,它将被调整大小Image
希望,这有帮助!