标签:XML ini size contex sda send ati length 压缩
使用下面两个方法,先按尺寸重绘图片,然后再降低品质上传图片data
#pragma mark 裁剪照片 -(UIImage *)scaleToSize:(UIImage *)image size:(CGSize)size { //创建一个bitmap的context //并把他设置成当前的context UIGraphicsBeginImageContext(size); //绘制图片的大小 [image drawInRect:CGRectMake(0, 0, size.width, size.height)]; //从当前context中创建一个改变大小后的图片 UIImage *endImage=UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return endImage; } - (void)printImageDataLength:(UIImage *)image { for (int i=1; i<= 10; i++) { NSData *data = UIImageJPEGRepresentation(image, i * 0.1); NSLog(@"JPEGdata.length%.1lf = %d",i * 0.1,data.length); } NSData *data = UIImagePNGRepresentation(image); NSLog(@"PNGdata.length = %d",data.length); }
标签:XML ini size contex sda send ati length 压缩
原文地址:https://www.cnblogs.com/ios-wmm/p/10216005.html