测试 NSImage / CGImageRef 是否完全透明的最佳方法
我有一个带有图块的图像,我将其拆分并创建单独的图块。
但是,这些图像通常包含我希望排除的完全空白区域(在本例中为图块)。这些区域是完全透明的。
现在,我该如何检测它们?可以通过 NSBitmapImageRep 逐像素读取图块,但这听起来效率不高。
那么测试图块透明度的最佳方法是什么(它们被裁剪为 CGImageRef ,然后转换为 NSImage - 如果有帮助的话)
I have an image with tiles that I am splitting up and creating individual tiles with.
However, these images typically contain completely blank areas (tiles in this case) that I wish to exclude. These areas are completely transparent.
Now, how do I go about detecting them? Could read the tile pixel by pixel, by way of NSBitmapImageRep
but that doesn't sound very efficient.
So what is the best way of testing the transparency of the tile (they are cropped to a CGImageRef
, then converted to an NSImage
- if that helps)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不介意使用仅限 10.6 的调用,那么您可以尝试
NSImage
方法,这比逐像素检查更容易,但我不这样做知道这样是否会更有效率。在某个地方,必须检查这些像素......
If you don't mind using using a 10.6-only call, then you could try the
NSImage
methodThis would be easier than checking pixel by pixel, but I don't know whether it would be more efficient. Somewhere down the line, those pixels have to be checked...