Try to fix decode image error message
This commit is contained in:
parent
6e99059007
commit
a7af2a19e4
|
@ -17,14 +17,13 @@
|
||||||
CGImageRef imageRef = image.CGImage;
|
CGImageRef imageRef = image.CGImage;
|
||||||
CGSize imageSize = CGSizeMake(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef));
|
CGSize imageSize = CGSizeMake(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef));
|
||||||
CGRect imageRect = (CGRect){.origin = CGPointZero, .size = imageSize};
|
CGRect imageRect = (CGRect){.origin = CGPointZero, .size = imageSize};
|
||||||
|
|
||||||
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
|
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||||
CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef);
|
CGContextRef context = CGBitmapContextCreate(NULL, imageSize.width, imageSize.height, CGImageGetBitsPerComponent(imageRef), CGImageGetBytesPerRow(imageRef), colorSpace, CGImageGetBitmapInfo(imageRef));
|
||||||
CGContextRef context;
|
|
||||||
context = CGBitmapContextCreate(NULL, imageSize.width, imageSize.height, 8, imageSize.width * 4, colorSpace, bitmapInfo);
|
|
||||||
CGColorSpaceRelease(colorSpace);
|
CGColorSpaceRelease(colorSpace);
|
||||||
|
|
||||||
if (!context) return nil;
|
// If failed, return undecompressed image
|
||||||
|
if (!context) return image;
|
||||||
|
|
||||||
CGContextDrawImage(context, imageRect, imageRef);
|
CGContextDrawImage(context, imageRect, imageRef);
|
||||||
CGImageRef decompressedImageRef = CGBitmapContextCreateImage(context);
|
CGImageRef decompressedImageRef = CGBitmapContextCreateImage(context);
|
||||||
|
|
Loading…
Reference in New Issue