ios对图像进行压缩源码
如下的资料是关于ios对图像进行压缩的内容。
{ CGSize imageSize = image.size; CGFloat width = imageSize.width; CGFloat height = imageSize.height; if (width <= newSize.width && height <= newSize.height){ return image; } if (width == 0 || height == 0){ return image; } CGFloat widthFactor = newSize.width / width; CGFloat heightFactor = newSize.height / height; CGFloat scaleFactor = (widthFactor<heightFactor?widthFactor:heightFactor); CGSize targetSize = CGSizeMake(scaledWidth,scaledHeight); UIGraphicsBeginImageContext(targetSize); [image drawInRect:CGRectMake(0,0,scaledWidth,scaledHeight)]; UIGraphicsEndImageContext(); return newImage;}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。