• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to grab content of CALayer and sublayers into a bitmap
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: How to grab content of CALayer and sublayers into a bitmap
      • From: Kevin Wojniak <email@hidden>
  • Prev by Date: Re: Flipping coordinate system of a CALayer
  • Next by Date: Re: WebView pagination for printing
  • Previous by thread: Re: Problem with category and obj-c++?
  • Next by thread: Re: How to grab content of CALayer and sublayers into a bitmap
  • Index(es):
    • Date
    • Thread