Skip navigation.
 
mlRe: Thread safe?
FROM : Jens Alfke
DATE : Sun Mar 30 19:02:31 2008

On 30 Mar '08, at 8:34 AM, Trygve Inda wrote:

> How did you work around this?
>
> Basically I am opening a bitmap drawing an NSImage into it, then 
> pixel-level
> tweaking the bitmap, and saving it to disk as a jpg.


You might want to drop down a level and use CGImage for your bitmap. 
CG is stateless (the graphics context is passed in to every drawing 
call) and doesn't do the types of offscreen caching that NSImage does, 
so it's more likely to be thread-safe.

You can use Cocoa graphics calls to draw into GCImages ... the recipe 
was discussed here in the last week or two, though I don't remember 
the details. You need to get a CG graphics context for drawing into 
the image, then make it the current NSGraphicsContext. (The books on 
Quartz 2D graphics probably discuss this too.)

—Jens

Related mailsAuthorDate
mlThread safe? Trygve Inda Mar 29, 14:44
mlRe: Thread safe? Jens Alfke Mar 29, 18:05
mlRe: Thread safe? Adam R. Maxwell Mar 29, 18:54
mlRe: Thread safe? Trygve Inda Mar 29, 20:20
mlRe: Thread safe? Adam R. Maxwell Mar 29, 20:48
mlRe: Thread safe? Thomas Engelmeier Mar 30, 15:10
mlRe: Thread safe? Adam R. Maxwell Mar 30, 17:01
mlRe: Thread safe? Trygve Inda Mar 30, 17:34
mlRe: Thread safe? Jens Alfke Mar 30, 19:02
mlRe: Thread safe? glenn andreas Mar 30, 19:14
mlRe: Thread safe? Trygve Inda Mar 30, 22:21
mlRe: Thread safe? glenn andreas Mar 30, 22:35
mlRe: Thread safe? Thomas Engelmeier Mar 31, 12:30