Depending on your needs, the CGWindow API may do what you want. It can generate 
images of windows, and then you could crop the image down. But if you're going 
for transparency that probably won't work.


On Jul 21, 2010, at 10:55 AM, Oleg Krupnov wrote:

> 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 (Cocoa-dev@lists.apple.com)
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/kainjow%40kainjow.com
> 
> This email sent to kain...@kainjow.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to