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[]
r开发者_如何学运维epresenting 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?
Try to set up PreviewFormat:
parameters.setPreviewFormat(ImageFormat.JPEG);
精彩评论