From 3322f248f6ef94d49113b09d43b3a0194f3ad867 Mon Sep 17 00:00:00 2001 From: Liam Don Date: Fri, 24 Feb 2017 09:35:47 -0800 Subject: [PATCH] Faster cropping --- FastttCamera/UIImage+FastttCamera.m | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/FastttCamera/UIImage+FastttCamera.m b/FastttCamera/UIImage+FastttCamera.m index 914582e..10c27a3 100644 --- a/FastttCamera/UIImage+FastttCamera.m +++ b/FastttCamera/UIImage+FastttCamera.m @@ -190,11 +190,10 @@ - (UIImage *)fastttImageWithNormalizedOrientation FastttRound(self.size.width), FastttRound(self.size.height)); - UIGraphicsBeginImageContextWithOptions(newRect.size, YES, self.scale); - [self drawInRect:newRect]; + CGImageRef imageRef = CGImageRetain(CGImageCreateWithImageInRect([self CGImage], newRect)); - UIImage *normalized = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); + UIImage *normalized = [UIImage imageWithCGImage:imageRef]; + CGImageRelease(imageRef); return normalized; }