• 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: Basic NSGraphicsContext question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Basic NSGraphicsContext question


  • Subject: Re: Basic NSGraphicsContext question
  • From: "Alastair J.Houghton" <email@hidden>
  • Date: Fri, 4 Jul 2003 21:31:09 +0100

On Friday, July 4, 2003, at 06:54 pm, Jim Crafton wrote:

First off I'll admit I am a complete newbie to OS X development (I am
coming from a Win32 background).
Is there a way to create an NSGraphicsContext from an image (I guess
similar to
CGCreateBitmapContext ?) to use for drawing, and then render the
contents of the NSGraphicsContext back to the one owned by a Window?

I think you probably want to look at the lockFocus and unlockFocus methods of NSImage. Something like

NSImage *myImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];

[myImage lockFocus];

// Draw here

[myImage unlockFocus];

will get you an NSImage that you can render to the window using the various compositing and/or drawing methods.

It's also worth mentioning that windows are typically buffered ("retained") in OS X, so there isn't any need to render to off-screen buffers to avoid flicker, unlike on Win32.

Kind regards,

Alastair.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Basic NSGraphicsContext question
      • From: Jim Crafton <email@hidden>
References: 
 >Basic NSGraphicsContext question (From: Jim Crafton <email@hidden>)

  • Prev by Date: What happened to Cocoa scitech portal?
  • Next by Date: Re: Basic NSGraphicsContext question
  • Previous by thread: Basic NSGraphicsContext question
  • Next by thread: Re: Basic NSGraphicsContext question
  • Index(es):
    • Date
    • Thread