我有一个相当大的几乎全屏的图像,我将在iPad上显示。图像大约80%透明。我需要在客户端上确定不透明像素的边界框,然后裁剪到该边界框。裁剪UIImage到alpha
在计算器上扫描其他的问题在这里和阅读一些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的面具或使用设备的图形加速来做到这一点?
你在设备上试过这个吗?我敢打赌它会比你想象的要快。 –
这是真的 - 一旦我真正坐下来实施它,处理时间比我想象的要快得多! – MikeQ