开发者

NSImage coordinate

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

[mBaseImage lockFocus];
NSBitmapImageRep* bitmapImageRep = [[NSBitmapImageR开发者_JS百科ep 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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜