且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在iPhone objective-c中降低图像质量/尺寸?

更新时间:2023-01-24 13:54:39

您可以创建图形上下文,将图像绘制成所需比例的图像,然后使用返回的图像。例如:

You can create a graphics context, draw the image into that at the desired scale, and use the returned image. For example:

UIGraphicsBeginImageContext(CGSizeMake(480,320));

CGContextRef            context = UIGraphicsGetCurrentContext();

[image drawInRect: CGRectMake(0, 0, 480, 320)];

UIImage        *smallImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();