Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NSImage lockFocus] and threads



Since this is the case, why would lockFocus through an exception then?

Here is the bit of code where I am using lockFocus:

- (NSImage*) resampleImage:(NSImage*)image toIconWidth:(int)iconWidth {
NSSize size;
NSSize thumbnailSize;
NSPoint origin;
NSImage *thumbnail;
NS_DURING
size = [image size];
if (size.width > size.height) {
thumbnailSize = NSMakeSize(iconWidth, iconWidth * size.height / size.width);
} else {
thumbnailSize = NSMakeSize(iconWidth * size.width / size.height, iconWidth);
};
origin.x = 0;
origin.y = 0;
thumbnail = [[NSImage alloc] initWithSize: thumbnailSize];
[thumbnail lockFocus];
//[image compositeToPoint: origin operation: NSCompositeCopy];
[image drawInRect: NSMakeRect(0, 0, thumbnailSize.width, thumbnailSize.height)
fromRect: NSMakeRect(0, 0, size.width, size.height)
operation: NSCompositeCopy fraction: 1.0];
[thumbnail unlockFocus];
NS_HANDLER
#if DEBUG
[debugLock lock];
NSLog(@"Exception Handled");
[debugLock unlock];
#endif
NS_ENDHANDLER
return thumbnail;
}


This method is called as a sub routine of a main method that was broken of as a thread. When I have several threads going, I get exceptions for about 10% of the calls to this function.

Any help with this would be greatly appreciated.




At 11:28 PM -0700 7/20/01, Aki Inoue wrote:
For both NSView & NSImage, the focus stack is provided for each thread.

So, you can safely lockFocus from multiple thread.

Aki

On 2001.07.20, at 22:51, Michael Horn wrote:

Can multiple threads have different lockFocus calls simultaneously or will one lockFocus called before a unlockFocus cause an exception to be raised? Thanks.
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev


References: 
 >Re: [NSImage lockFocus] and threads (From: Aki Inoue <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.