iOS:压缩图片

UIImage*img= [self imageWithImageSimple:image scaledToSize:CGSizeMake(210.0, 210.0)];//压缩图片

- (UIImage*)imageWithImageSimple:(UIImage*)image scaledToSize:(CGSize)newSize
{
     // Create a graphics image context
     UIGraphicsBeginImageContext(newSize); // Tell the old image to draw in this newcontext, with the desired
    
     // new size
     [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
    
     // Get the new image from the context
     UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
     
     // End the context
     UIGraphicsEndImageContext();
     
     // Return the new image.
     return newImage;
}   

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。