我有一个相当大的,几乎全屏的图像,我将在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);
Run Code Online (Sandbox Code Playgroud)
这似乎非常低效和笨重.有没有什么聪明的我可以使用CGImage蒙版或利用设备的图形加速来做到这一点?