Re: BitMap data format and autorelease
Re: BitMap data format and autorelease
- Subject: Re: BitMap data format and autorelease
- From: "Adam R. Maxwell" <email@hidden>
- Date: Thu, 13 Mar 2008 18:03:07 -0700
On Mar 13, 2008, at 5:44 PM, Trygve Inda wrote:
I'd use something like this (typed in Mail):
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:[NSGraphicsContext
graphicsContextWithBitmapImageRep:imageRep]];
// draw here
[NSGraphicsContext restoreGraphicsState];
which avoids creating an NSImage.
Is this thread-safe? Or is it better to create the NSImage so I can
call
lockFocus ?
This should be thread safe (don't draw into it from multiple threads
at the same time, of course, without appropriate locking). The -
lockFocus call does nothing for thread safety per se AFAIK; it just
sets up the graphics context. If you're manipulating pixels directly,
I'd avoid NSImage as much as possible since it's caching can be
confusing.
--
adam
_______________________________________________
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