iPhone Objective C:UIImage - 感兴趣区域
有没有办法获得包含 UIImage 的所有非透明部分的最小矩形区域?
我认为,逐像素读取以检查 alpha == 0 的位置......这不是一个好方法。
还有更好的办法吗?
非常感谢您的阅读
Is there any way to get the min rectangle area which contains all the non-transparent part of an UIImage?
Reading pixel by pixel to check where alpha == 0 ...isn't a good way I believe.
Any better way?
Many thanks for reading
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为没有办法在不逐像素检查图像的情况下做到这一点。图像来自哪里?如果你控制它们,你至少可以只逐个像素地执行一次,然后缓存信息或将其与图像一起分发(如果人们下载它们)。
I don't think there's a way to do this without examining the image pixel by pixel. Where are the images coming from? If you control them, you can at least do the pixel by pixel part only once and then either cache the information or distribute it along with the images if people are downloading them.
好吧,这是我对这个问题的丑陋解决方案。我希望有更好的方法来做到这一点。
Okay here is my ugly solution to this problem. I hope there is a better way to do this.