Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onPreviewFrame(final byte[] data, android.hardware.Camera callbackCamera) {
- Camera.Parameters parameters = callbackCamera.getParameters();
- int imageFormat = parameters.getPreviewFormat();
- if (imageFormat == ImageFormat.NV21)
- {
- Rect rect = new Rect(0, 0, 320, 240);
- YuvImage img = new YuvImage(data, ImageFormat.NV21, 320, 240, null);
- OutputStream outStream = null;
- File file = new File(Environment.getExternalStorageDirectory().getPath() + File.separator +
- "VID_local_image" + ".jpg");
- try
- {
- outStream = new FileOutputStream(file);
- img.compressToJpeg(rect, 100, outStream);
- outStream.flush();
- outStream.close();
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment