private void sendImage() {
if (getContainer() == null || lastSnapshot == null) {
return;
}
int width = params.getPreviewSize().width;
int height = params.getPreviewSize().height;
Rect rect = new Rect(0, 0, width, height);
YuvImage yuvimage = new YuvImage(lastSnapshot, ImageFormat.NV21, width, height, null);
try (ByteArrayOutputStream outStream = new ByteArrayOutputStream()) {
yuvimage.compressToJpeg(rect, 80, outStream);
byte[] jpegData = outStream.toByteArray();
CameraPayload payload = new CameraPayload(getCameraID(), getModuleName());
payload.setPicture(jpegData);
Message reply = new Message(payload);
requireComponent(OutgoingRouter.KEY).sendReply(getReplyToMessage(), reply);
imageSent = true;
//File file = new File(Environment.getExternalStorageDirectory().getPath(),
// "snapshot" + System.currentTimeMillis() + ".jpg");
//FileOutputStream outstr = new FileOutputStream(file);
//yuvimage.compressToJpeg(rect, 80, outstr);
} catch (IOException e) {
Log.e(TAG, "Could not compress image", e);
}
finish();
}
OdroidCamera.java 文件源码
java
阅读 18
收藏 0
点赞 0
评论 0
项目:SecureSmartHome
作者:
评论列表
文章目录