• 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: Thread safe?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thread safe?


  • Subject: Re: Thread safe?
  • From: Trygve Inda <email@hidden>
  • Date: Sun, 30 Mar 2008 15:34:19 +0000
  • Thread-topic: Thread safe?

>
> On 29.03.2008, at 18:54, Adam R. Maxwell wrote:
>>
>> Drawing into an NSImage is explicitly documented to be thread safe
>> in the article you linked to, and each thread has its own graphics
>> context.  The post I linked to does indicate that you might want to
>> use [image setCacheMode:NSImageCacheNever].  If your goal is just to
>> get an NSBitmapImageRep from a file, it's probably easier just to
>> use +imageRepWithContentsOfFile:.
>
> While it is documented to be thread save you might get crashes later
> when an NSBitmapImageRep created by drawing into from an secondary
> thread gets drawn itself. The crash occurs when the image tries to
> access an NULL (offscreen) window context (it probably was originally
> drawn into).
>
> Tried to debug that on 10.5.2 (and simply worked around)...

This will never be drawn to the screen, but will be saved to disk:

NSDictionary*    imageProps = [NSDictionary dictionaryWithObject:[NSNumber
numberWithFloat:0.9] forKey:NSImageCompressionFactor];

NSData*            imageData = [myImageRep
representationUsingType:NSJPEGFileType properties:imageProps];

[imageData writeToFile:path atomically:NO];

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.

Trygve


_______________________________________________

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

  • Follow-Ups:
    • Re: Thread safe?
      • From: Jens Alfke <email@hidden>
References: 
 >Re: Thread safe? (From: Thomas Engelmeier <email@hidden>)

  • Prev by Date: Re: Thread safe?
  • Next by Date: How to set color file labels?
  • Previous by thread: Re: Thread safe?
  • Next by thread: Re: Thread safe?
  • Index(es):
    • Date
    • Thread