How do I reduce Image quality/size in iPhone objective-c?

前端 未结 3 1805
甜味超标
甜味超标 2020-12-09 05:29

I have an app that lets the user take a picture with his/her iPhone and use it as a background image for the app. I use UIImagePickerController to let the user

3条回答
  •  佛祖请我去吃肉
    2020-12-09 06:02

    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();    
    

提交回复
热议问题