views:

31

answers:

1

hey guys, I have a large image, and then i'm extracting a portion of the image out via:

[mBaseImage lockFocus];
NSBitmapImageRep* bitmapImageRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect: NSMakeRect(startX,startY,width,height)];
[mBaseImage unlockFocus];

followed by:

extractedImage = [[NSImage alloc] initWithSize:[bitmapImageRep size]];
[extractedImage addRepresentation:bitmapImageRep];

where extractedImage is NSImage *.

Later on while i'm trying to draw the extractedImage using NSDrawNinePartImage, I realised that while I was specifying the 9 parts following the example at http://www.karlkraft.com/index.php/2007/11/14/nsdrawninepartimage/ I realised that when i specified 0,0 it shows the upper left handcorner of the image, which means that 0,0 is the upper left hand corner instead of the lower left hand corner like in the example in the link. I tried setting the setFlipped however it seems to be only flipping the image. does anyone have any idea how I can get the coordinates back to where 0,0 is at the bottom left?

Oh and I forgot to mention that i'm using the image as a button, so it's presented as a NSButton.

Regards, Han

A: 

Ok i found it. It was a rogue [image setFlip:...] somewhere in the code that was causing all the mixup..

han
Please note that -[NSImage setFlipped:] is deprecated. For more discussion see the AppKit release notes at http://developer.apple.com/library/mac/#releasenotes/Cocoa/AppKit.html
Ken
Thank you ken :)
han