Created
November 10, 2010 06:31
-
-
Save alanjrogers/670450 to your computer and use it in GitHub Desktop.
Creating a CGImage from a CALayer tree.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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