Authored by Olivier Poitrey

Fix disk image cache read not setting memory cache + ensure decodedImageWithImage never fail

... ... @@ -191,16 +191,10 @@ static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week
dispatch_data_apply(dispatchedData, (dispatch_data_applier_t)^(dispatch_data_t region, size_t offset, const void *buffer, size_t size)
{
UIImage *diskImage = SDScaledImageForPath(key, [NSData dataWithBytes:buffer length:size]);
UIImage *diskImage = [UIImage decodedImageWithImage:SDScaledImageForPath(key, [NSData dataWithBytes:buffer length:size])];
if (image)
if (diskImage)
{
UIImage *decodedImage = [UIImage decodedImageWithImage:diskImage];
if (decodedImage)
{
diskImage = decodedImage;
}
[self.memCache setObject:diskImage forKey:key cost:image.size.height * image.size.width * image.scale];
}
... ...
... ... @@ -35,7 +35,7 @@
colorSpace,
bitmapInfo);
CGColorSpaceRelease(colorSpace);
if (!context) return nil;
if (!context) return image;
CGRect rect = (CGRect){CGPointZero,{CGImageGetWidth(imageRef), CGImageGetHeight(imageRef)}};
CGContextDrawImage(context, rect, imageRef);
... ...