Guest User

Untitled

a guest
Feb 19th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. @Override
  2. public void onPreviewFrame(final byte[] data, android.hardware.Camera callbackCamera) {
  3. Camera.Parameters parameters = callbackCamera.getParameters();
  4. int imageFormat = parameters.getPreviewFormat();
  5. if (imageFormat == ImageFormat.NV21)
  6. {
  7. Rect rect = new Rect(0, 0, 320, 240);
  8. YuvImage img = new YuvImage(data, ImageFormat.NV21, 320, 240, null);
  9. OutputStream outStream = null;
  10. File file = new File(Environment.getExternalStorageDirectory().getPath() + File.separator +
  11. "VID_local_image" + ".jpg");
  12. try
  13. {
  14. outStream = new FileOutputStream(file);
  15. img.compressToJpeg(rect, 100, outStream);
  16. outStream.flush();
  17. outStream.close();
  18. }
  19. catch (FileNotFoundException e)
  20. {
  21. e.printStackTrace();
  22. }
  23. catch (IOException e)
  24. {
  25. e.printStackTrace();
  26. }
  27. }
  28. }
Add Comment
Please, Sign In to add comment