From e6ebc486e7d50480613ffadeb93de518c1711d41 Mon Sep 17 00:00:00 2001 From: Pingan Yi Date: Thu, 22 Jan 2015 18:46:02 +0800 Subject: [PATCH] Memory optimization for big image if rotation disabled pe_rotatedImageWithtransform will consume much Memory if original image is large. if not rotation, pe_rotatedImageWithtransform are not needed. --- Lib/UIImage+PECrop.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/UIImage+PECrop.m b/Lib/UIImage+PECrop.m index ef389b8..fc356fc 100644 --- a/Lib/UIImage+PECrop.m +++ b/Lib/UIImage+PECrop.m @@ -13,8 +13,11 @@ @implementation UIImage (PECrop) - (UIImage *)rotatedImageWithtransform:(CGAffineTransform)rotation croppedToRect:(CGRect)rect { - UIImage *rotatedImage = [self pe_rotatedImageWithtransform:rotation]; - + UIImage *rotatedImage = self; + if (!CGAffineTransformIsIdentity(rotation)) { + rotatedImage = [self pe_rotatedImageWithtransform:rotation]; + } + CGFloat scale = rotatedImage.scale; CGRect cropRect = CGRectApplyAffineTransform(rect, CGAffineTransformMakeScale(scale, scale));