NS图像坐标
嘿伙计们, 我有一个大图像,然后我通过以下方式提取图像的一部分:
[mBaseImage lockFocus];
NSBitmapImageRep* bitmapImageRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect: NSMakeRect(startX,startY,width,height)];
[mBaseImage unlockFocus];
后跟:
extractedImage = [[NSImage alloc] initWithSize:[bitmapImageRep size]];
[extractedImage addRepresentation:bitmapImageRep];
其中 extractedImage 是 NSImage *。
后来,当我尝试使用 NSDrawNinePartImage 绘制提取的图像时,我意识到虽然我按照 http://www.karlkraft.com/index.php/2007/11/14/nsdrawninepartimage/ 我意识到,当我指定 0,0 时,它显示图像的左上角,这意味着 0,0 是左上角,而不是像链接中的示例中的左下角。我尝试设置 setFlipped 但它似乎只是翻转图像。有谁知道如何将坐标返回到左下角 0,0 的位置吗?
哦,我忘了提及,我使用图像作为按钮,因此它呈现为 NSButton。
问候, 汉族
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我找到了。这是代码中某个地方的一个流氓 [image setFlip:...] 导致了所有的混淆。
Ok i found it. It was a rogue [image setFlip:...] somewhere in the code that was causing all the mixup..