原
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa版权协议,转载请附上原文出处链接和本声明。
// ------这种方法对图片既进行压缩,又进行裁剪 - (NSData *)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize; {UIGraphicsBeginImageContext(newSize); [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];UIImage* newImage =UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();returnUIImageJPEGRepresentation(newImage,0.8); } // ------调用UIImage *img = [UIImage imageWithData:[self imageWithImage:image scaledToSize:CGSizeMake(300,300)]]
原文链接:http://www.jianshu.com/p/cd8cea425067
Android