• 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: Creating an NSImage of a View and its Contents
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating an NSImage of a View and its Contents


  • Subject: Re: Creating an NSImage of a View and its Contents
  • From: Stephen Blinkhorn <email@hidden>
  • Date: Tue, 21 Dec 2010 16:19:35 -0600

On 21 Dec 2010, at 15:10, Corbin Dunn wrote:

I'll just copy the code here for you:

NSRect visibleRect = [_oldContentView visibleRect];
NSBitmapImageRep *imageRep = [_oldContentView bitmapImageRepForCachingDisplayInRect:visibleRect];
[_oldContentView cacheDisplayInRect:visibleRect toBitmapImageRep:imageRep];

Thanks Corbin, will try this technique out now. Stephen






http://developer.apple.com/library/mac/#samplecode/AnimatedTableView/ Listings/ATPopupWindow_m.html



corbin


On Dec 21, 2010, at 1:08 PM, Corbin Dunn wrote:

Hi Stephen,
This was done in the AnimatedTableView demo app available on the dev site. Check it out and let me know if you need pointing to the particular part of code that does it.


corbin

On Dec 21, 2010, at 12:11 PM, Stephen Blinkhorn wrote:

Hi all,

I'm trying to capture a view and its contents as an NSImage which I can subsequently draw in the view. The idea is that I'm trying to 'freeze' the view's content (custom sliders, buttons, menus etc) and present this image in the view.

I'm getting mixed results when attempting to render to a CFLayerRef e.g.:

NSRect viewRect = [self bounds];

[self lockFocus];
NSBitmapImageRep* rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:viewRect];
[self unlockFocus];

NSImage* image = [[NSImage alloc] initWithSize:viewRect.size];
[image addRepresentation:rep];
[image drawAtPoint:NSZeroPoint fromRect:viewRect operation:NSCompositeSourceOver fraction:1.0];

[image release];
[rep release];



Nothing appears to be drawn in the layer. Is there a better approach that I'm missing?


Thanks,
Stephen
_______________________________________________

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: 
 >Creating an NSImage of a View and its Contents (From: Stephen Blinkhorn <email@hidden>)
 >Re: Creating an NSImage of a View and its Contents (From: Corbin Dunn <email@hidden>)
 >Re: Creating an NSImage of a View and its Contents (From: Corbin Dunn <email@hidden>)

  • Prev by Date: Re: Creating an NSImage of a View and its Contents
  • Next by Date: Vertical Asian Text in Cocoa
  • Previous by thread: Re: Creating an NSImage of a View and its Contents
  • Next by thread: Vertical Asian Text in Cocoa
  • Index(es):
    • Date
    • Thread