• 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
Re: How to grab content of CALayer and sublayers into a bitmap
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to grab content of CALayer and sublayers into a bitmap


  • Subject: Re: How to grab content of CALayer and sublayers into a bitmap
  • From: Kevin Wojniak <email@hidden>
  • Date: Thu, 22 Jul 2010 08:35:55 -0700

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 (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

_______________________________________________

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

References: 
 >How to grab content of CALayer and sublayers into a bitmap (From: Oleg Krupnov <email@hidden>)

  • Prev by Date: Re: Knowing how a Text Editing Session ended
  • Next by Date: Small caps in NSTextView
  • Previous by thread: How to grab content of CALayer and sublayers into a bitmap
  • Next by thread: UIImage Color Overlay
  • Index(es):
    • Date
    • Thread