From 2e0bfbd7a6dcc60456d68e16ec8b9c689260f128 Mon Sep 17 00:00:00 2001 From: Rodrigo Navarro Date: Wed, 6 Nov 2013 15:53:45 -0200 Subject: [PATCH 1/2] Fixing CGContextTranslateCTM: invalid context 0x0 This errors happens when the `visibleArea` width or height are zero. --- RealTimeBlur/Classes/DRNRealTimeBlurView.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RealTimeBlur/Classes/DRNRealTimeBlurView.m b/RealTimeBlur/Classes/DRNRealTimeBlurView.m index 1456ce6..bcddefb 100644 --- a/RealTimeBlur/Classes/DRNRealTimeBlurView.m +++ b/RealTimeBlur/Classes/DRNRealTimeBlurView.m @@ -201,7 +201,8 @@ - (void)renderLayerWithView:(UIView*)superview [self toggleBlurViewsInView:superview hidden:YES alpha:alpha]; //Render the layer in the image context - //Render the layer in the image context + if (visibleRect.size.width == 0 || visibleRect.size.height == 0) return; + UIGraphicsBeginImageContextWithOptions(visibleRect.size, NO, 1.0); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextTranslateCTM(context, -visibleRect.origin.x, -visibleRect.origin.y); From f92435ed35c2e786f89f24cfa66a7172aa908445 Mon Sep 17 00:00:00 2001 From: Rodrigo Navarro Date: Thu, 5 Dec 2013 11:49:24 -0200 Subject: [PATCH 2/2] Using CGRectIsEmpty to check if the rectangle has no width and height. --- RealTimeBlur/Classes/DRNRealTimeBlurView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RealTimeBlur/Classes/DRNRealTimeBlurView.m b/RealTimeBlur/Classes/DRNRealTimeBlurView.m index bcddefb..4c734eb 100644 --- a/RealTimeBlur/Classes/DRNRealTimeBlurView.m +++ b/RealTimeBlur/Classes/DRNRealTimeBlurView.m @@ -201,7 +201,7 @@ - (void)renderLayerWithView:(UIView*)superview [self toggleBlurViewsInView:superview hidden:YES alpha:alpha]; //Render the layer in the image context - if (visibleRect.size.width == 0 || visibleRect.size.height == 0) return; + if (CGRectIsEmpty(visibleRect)) return; UIGraphicsBeginImageContextWithOptions(visibleRect.size, NO, 1.0); CGContextRef context = UIGraphicsGetCurrentContext();