• 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: Sat, 29 Mar 2008 19:20:56 +0000
  • Thread-topic: Thread safe?

> Yes.  See
>
> http://www.cocoabuilder.com/archive/message/cocoa/2007/11/15/193191
>
> ISTR having problems specifying a nonzero bytesPerRow and passing NULL
> for the bitmap data, so you might need to either manage the buffer
> yourself or pass zero for bytesPerRow to allow NSBitmapImageRep to pad
> it appropriately.

Many thanks.

>>
>>    [segImageRep dealloc];

> You should never call dealloc directly (well, unless you've overridden
> -retain/-release to handle your own refcounting).

Good catch!

>> How about:
>>
>> NSImage *    image = [[[NSImage alloc] initWithContentsOfFile:path]
>> autorelease];
>>
>>    [NSGraphicsContext saveGraphicsState];
>>    [NSGraphicsContext setCurrentContext:[NSGraphicsContext
>> graphicsContextWithBitmapImageRep:segImageRep]];
>>
>>    [image drawInRect:NSMakeRect(0, 0, [image size].width, [image
>> size].height) fromRect:NSMakeRect(0, 0, [image size].width, [image
>> size].height) operation:NSCompositeCopy fraction:1.0];
>>
>>    [NSGraphicsContext restoreGraphicsState];
>
> Drawing into an NSImage is explicitly documented to be thread safe in
> the article you linked to,

I guess I was more concerned with the initWithContentsOfFile:path

> 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:.

This could work, but as I need to do pixel level manipulation, I really need
to know the exact format of the bitmap and this does not seem to let me
specify it.

Cheers,

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: "Adam R. Maxwell" <email@hidden>
References: 
 >Re: Thread safe? (From: "Adam R. Maxwell" <email@hidden>)

  • Prev by Date: Use of a int type property
  • Next by Date: Re: NSScroller question
  • Previous by thread: Re: Thread safe?
  • Next by thread: Re: Thread safe?
  • Index(es):
    • Date
    • Thread