Skip to content

Commit

Permalink
Fixed issue with opaque thumbnails being given an alpha channel
Browse files Browse the repository at this point in the history
Summary:Images cropped using the ImageEditor were always given an alpha channel, even if opaque.

This causes them to be saved as PNGs instead of JPEGs (increasing memory and bridge traffic) and also causes unnecessary blending when they are drawn.

Reviewed By: fkgozali

Differential Revision: D2982682

fb-gh-sync-id: b65f361efd78e35f259836111b38d914bae49847
shipit-source-id: b65f361efd78e35f259836111b38d914bae49847
  • Loading branch information
nicklockwood authored and Facebook Github Bot 3 committed Feb 26, 2016
1 parent f99579a commit 7383378
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Libraries/Image/RCTImageUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ BOOL RCTUpscalingRequired(CGSize sourceSize, CGFloat sourceScale,
return nil;
}

UIGraphicsBeginImageContextWithOptions(destSize, NO, destScale);
BOOL opaque = !RCTImageHasAlpha(image.CGImage);
UIGraphicsBeginImageContextWithOptions(destSize, opaque, destScale);
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextConcatCTM(currentContext, transform);
[image drawAtPoint:CGPointZero];
Expand Down

0 comments on commit 7383378

Please sign in to comment.