GeezerVison is showing github.com — feat: update up 4.4.7. · iOSCopder/SDWebImage@8185423
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: SDWebImage.podspec +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | Pod::Spec.new do |s| |
2 | 2 | s.name = 'SDWebImage' |
3 | | - s.version = '4.4.6' |
| 3 | + s.version = '4.4.7' |
4 | 4 |
|
5 | 5 | s.osx.deployment_target = '10.9' |
6 | 6 | s.ios.deployment_target = '7.0' |
|
Collapse file
Copy file name to clipboardExpand all lines: SDWebImage/SDImageCache.h +19Lines changed: 19 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -134,6 +134,25 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot |
134 | 134 | toDisk:(BOOL)toDisk |
135 | 135 | completion:(nullable SDWebImageNoParamsBlock)completionBlock; |
136 | 136 |
|
| 137 | +/** |
| 138 | + * Asynchronously store an image into memory and disk cache at the given key. |
| 139 | + * |
| 140 | + * @param image The image to store |
| 141 | + * @param imageData The image data as returned by the server, this representation will be used for disk storage |
| 142 | + * instead of converting the given image object into a storable/compressed image format in order |
| 143 | + * to save quality and CPU |
| 144 | + * @param key The unique image cache key, usually it's image absolute URL |
| 145 | + * @param toDisk Store the image to disk cache if YES |
| 146 | + * @param isJPEG Store the image to JPEG if YES |
| 147 | + * @param completionBlock A block executed after the operation is finished |
| 148 | + */ |
| 149 | +- (void)storeImage:(nullable UIImage *)image |
| 150 | + imageData:(nullable NSData *)imageData |
| 151 | + forKey:(nullable NSString *)key |
| 152 | + toDisk:(BOOL)toDisk |
| 153 | + isJPEG:(BOOL)isJPEG |
| 154 | + completion:(nullable SDWebImageNoParamsBlock)completionBlock; |
| 155 | + |
137 | 156 | /** |
138 | 157 | * Asynchronously store an image into memory and disk cache at the given key. |
139 | 158 | * |
|
Collapse file
Copy file name to clipboardExpand all lines: SDWebImage/SDImageCache.m +10-1Lines changed: 10 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -285,6 +285,15 @@ - (void)storeImage:(nullable UIImage *)image |
285 | 285 | forKey:(nullable NSString *)key |
286 | 286 | toDisk:(BOOL)toDisk |
287 | 287 | completion:(nullable SDWebImageNoParamsBlock)completionBlock { |
| 288 | + [self storeImage:image imageData:imageData forKey:key toDisk:toDisk isJPEG:NO completion:completionBlock]; |
| 289 | +} |
| 290 | + |
| 291 | +- (void)storeImage:(nullable UIImage *)image |
| 292 | + imageData:(nullable NSData *)imageData |
| 293 | + forKey:(nullable NSString *)key |
| 294 | + toDisk:(BOOL)toDisk |
| 295 | + isJPEG:(BOOL)isJPEG |
| 296 | + completion:(nullable SDWebImageNoParamsBlock)completionBlock { |
288 | 297 | if (!image || !key) { |
289 | 298 | if (completionBlock) { |
290 | 299 | completionBlock(); |
@@ -304,7 +313,7 @@ - (void)storeImage:(nullable UIImage *)image |
304 | 313 | if (!data && image) { |
305 | 314 | // If we do not have any data to detect image format, check whether it contains alpha channel to use PNG or JPEG format |
306 | 315 | SDImageFormat format; |
307 | | - if (SDCGImageRefContainsAlpha(image.CGImage)) { |
| 316 | + if (!isJPEG && SDCGImageRefContainsAlpha(image.CGImage)) { |
308 | 317 | format = SDImageFormatPNG; |
309 | 318 | } else { |
310 | 319 | format = SDImageFormatJPEG; |
|