How to grab content of CALayer and sublayers into a bitmap
How to grab content of CALayer and sublayers into a bitmap
- Subject: How to grab content of CALayer and sublayers into a bitmap
- From: Oleg Krupnov <email@hidden>
- Date: Wed, 21 Jul 2010 20:55:26 +0300
Hi,
I need to make a snapshot of a CALayer, together with all its
sublayers and effects, into a bitmap.
I've found I can use -[CALayer renderInContext:], but I find it too
slow, particularly because some of the sublayers have shadows and the
Shark shows that most of time is spent in calculating blur
convolutions of the shadows.
On the other hand, all those shadows are already rendered to the
screen, so theoretically there is no need to render them again.
Is there a way I could directly grab what I see in the layer into a bitmap?
What I have already tried:
-[NSBitmapImageRep initWithFocusedViewRect:] -- doesn't work, shows
empty box instead of the layer-hosting view
- [NSView cacheDisplayInRect:] -- does not work unless you put
-[CALayer renderInContext:] into the layer-hosting view's -drawRect:,
so see the problem above
The content of layers is drawn using -[CALayer drawLayer:inContext:]
Thanks,
Oleg.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden