我是一個(gè)搬運(yùn)工,只會(huì)copy非迹,轉(zhuǎn)載轉(zhuǎn)載轉(zhuǎn)載:https://blog.csdn.net/benyoulai5/article/details/50462586
4.0.3版本時(shí)惯裕,可以改????
[SDImageCache sharedImageCache].config.shouldDecompressImages = NO; ? ?[SDWebImageDownloader sharedDownloader].shouldDecompressImages = NO;
5.0.6版本時(shí)玄叠,以上屬性不見(jiàn)了欣尼,看此鏈接https://blog.csdn.net/benyoulai5/article/details/50462586,
SDImageIOCoder.m 中
- (UIImage*)decodedImageWithData:(NSData*)dataoptions:(nullableSDImageCoderOptions*)options {
? ? if(!data) {
? ? ? ? returnnil;
? ? }
? ? CGFloatscale =1;
? ? NSNumber*scaleFactor = options[SDImageCoderDecodeScaleFactor];
? ? if(scaleFactor !=nil) {
? ? ? ? scale =MAX([scaleFactor doubleValue],1) ;
? ? }
? ? UIImage*image = [[UIImagealloc]initWithData:datascale:scale];
? ? if(data.length/1024>128) {
? ? ? ? image = [selfcompressImageWith:image];
? ? }
? ? image.sd_imageFormat = [NSData sd_imageFormatForImageData:data];
? ? returnimage;
}
-(UIImage *)compressImageWith:(UIImage *)image
{
? ? floatimageWidth = image.size.width;
? ? floatimageHeight = image.size.height;
? ? floatwidth =640;
? ? floatheight = image.size.height/(image.size.width/width);
? ? floatwidthScale = imageWidth /width;
? ? floatheightScale = imageHeight /height;
? ? // 創(chuàng)建一個(gè)bitmap的context
? ? // 并把它設(shè)置成為當(dāng)前正在使用的context
? ? UIGraphicsBeginImageContext(CGSizeMake(width, height));
? ? if(widthScale > heightScale) {
? ? ? ? [imagedrawInRect:CGRectMake(0,0, imageWidth /heightScale , height)];
? ? }
? ? else{
? ? ? ? [imagedrawInRect:CGRectMake(0,0, width , imageHeight /widthScale)];
? ? }
? ? // 從當(dāng)前context中創(chuàng)建一個(gè)改變大小后的圖片
? ? UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
? ? // 使當(dāng)前的context出堆棧
? ? UIGraphicsEndImageContext();
? ? returnnewImage;
}