Camera 对象上的 setOneShotPreviewCallback(),预览图像的裁剪版本
我正在开发一个相当需要进程的应用程序,我需要在每次按下按钮时拍摄图像并保存它。按下按钮后,我会触发相机对象的 setOneShotPreviewCallback()
方法,以获取表示当时图像的 byte[]
。在此之后,我使用这个 byte[]
并使用 YUVImage 对象将其转换为位图,这对处理器来说非常繁重。为了减少这种情况,我使用以下方法裁剪图像:
Rect rect = new Rect(4*w/10, 0, 9*w/10, h);
final ByteArrayOutputStream output_stream = new ByteArrayOutputStream();
yuv_image.compressToJpeg(rect, 100, output_stream);
我想知道是否可以仅使用 byte[]
来做到这一点,而不必将其转换为 YUV 图像?就像在触发回调之前一样,创建了 Rect,并且 byte[]
仅填充了该 Rect 内的图像数据?
I am developing a fairly process hungry application which I need to take an image and save it every time a button is pressed. On pressing the button I trigger the setOneShotPreviewCallback()
method of the camera object to get a byte[]
representing the image at that moment. At the moment after this I take this byte[]
and convert that to a bitmap using a YUVImage object which is very heavy on the processor. To reduce this I crop the image using:
Rect rect = new Rect(4*w/10, 0, 9*w/10, h);
final ByteArrayOutputStream output_stream = new ByteArrayOutputStream();
yuv_image.compressToJpeg(rect, 100, output_stream);
I would like to know if I can do this only using the byte[]
and not have to convert it to the YUV Image? like before the callback is triggered the Rect is created and the byte[]
is only populated with the image data inside that Rect?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试设置 PreviewFormat:
Try to set up PreviewFormat: