Skip to content

Instantly share code, notes, and snippets.

@alanjrogers
Created November 10, 2010 06:31
Show Gist options
  • Save alanjrogers/670450 to your computer and use it in GitHub Desktop.
Save alanjrogers/670450 to your computer and use it in GitHub Desktop.
Creating a CGImage from a CALayer tree.
CGSize imageSize = CGSizeMake(1000, 1000);
CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
CGContextRef theContext = CGBitmapContextCreate(NULL, imageSize.width, imageSize.height, 8, 4*imageSize.width, colorSpace, kCGImageAlphaPremultipliedLast);
[layerView.layer renderInContext:theContext];
// Layer tree has backgroundFilters set on some of the CALayers
// When it's rendered in the Bitmap Context, none of these filters are applied.
CGImageRef CGImage = (CGBitmapContextCreateImage(theContext);
// Can no do this, but no point cause filters have already NOT been applied.
// CIImage* image = [CIImage imageWithCGImage:CGImage];
// Was hoping to find a way to get a CALayer hierarchy to provide content for a CIImage and inside a CIContext
// to ensure that the CIFilters are applied correctly
// Currently looking into CARenderer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment