图片压缩问题

2018-02-07  本文已影响0人  KS小么

使用UIImagePNGRepresentation和UIImageJPEGRepresentation来压缩图片, 文件属性格式并不会压缩,压缩的是图片内容(像素)压缩后的图片显示到屏幕上还是会很占内存,使用 上下文生成bitmap图像可以进行压缩  方法如下

- (UIImage*)scaleImage:(UIImage*)image size:(CGSize)imageSize{        

    UIGraphicsBeginImageContext(imageSize);

    [image drawInRect:CGRectMake(0, 0, imageSize.width, imageSize.height)];

    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return newImage;

}

上一篇 下一篇

猜你喜欢

热点阅读