【发布时间】:2011-09-25 04:55:42
【问题描述】:
我有一个相当大的、几乎全屏的图像,我将在 iPad 上显示它。图像大约 80% 透明。我需要在客户端确定不透明像素的边界框,然后裁剪到该边界框。
扫描 StackOverflow 上的其他问题并阅读一些 CoreGraphics 文档,我想我可以通过以下方式完成:
CGBitmapContextCreate(...) // Use this to render the image to a byte array
..
- iterate through this byte array to find the bounding box
..
CGImageCreateWithImageInRect(image, boundingRect);
这似乎非常低效且笨拙。我可以用 CGImage 蒙版或利用设备的图形加速来做这件事吗?
【问题讨论】:
-
你在设备上试过了吗?我敢打赌它会比你想象的要快。
-
确实如此——一旦我真正坐下来实施它,处理时间比我想象的要快得多!
标签: ios ipad ios4 core-graphics cgimage