Skip to content

Commit

Permalink
FIX (code): No blur after "fix CGContextTranslateCTM: invalid context…
Browse files Browse the repository at this point in the history
… 0x0".
  • Loading branch information
duffpod committed Sep 24, 2013
1 parent f840265 commit c941ba6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions RealTimeBlur/Classes/DRNRealTimeBlurView.m
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,17 @@ - (void)renderLayerWithView:(UIView*)superview

visibleRect.origin.y += self.frame.origin.y;
visibleRect.origin.x += self.frame.origin.x;

//hide all the blurred views from the superview before taking a screenshot
CGFloat alpha = self.alpha;
CGFloat alpha = self.alpha;
[self toggleBlurViewsInView:superview hidden:YES alpha:alpha];

//Render the layer in the image context
UIGraphicsBeginImageContextWithOptions(visibleRect.size, NO, 1.0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, -visibleRect.origin.x, -visibleRect.origin.y);
CALayer *layer = superview.layer;
[layer renderInContext:UIGraphicsGetCurrentContext()];
[layer renderInContext:context];

//show all the blurred views from the superview before taking a screenshot
[self toggleBlurViewsInView:superview hidden:NO alpha:alpha];
Expand All @@ -216,13 +218,13 @@ - (void)renderLayerWithView:(UIView*)superview
UIGraphicsEndImageContext();

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{

//takes a screenshot of that portion of the screen and blurs it
//helps w/ our colors when blurring
//feel free to adjust jpeg quality (lower = higher perf)
NSData *imageData = UIImageJPEGRepresentation(image, kDRNRealTimeBlurViewScreenshotCompression);
image = [[UIImage imageWithData:imageData] drn_boxblurImageWithBlur:_blurRadius];

dispatch_sync(dispatch_get_main_queue(), ^{
//update the layer content
self.layer.contents = (id)image.CGImage;
Expand Down

0 comments on commit c941ba6

Please sign in to comment.