List of usage examples for android.hardware.camera2 DngCreator writeByteBuffer
public void writeByteBuffer(@NonNull OutputStream dngOutput, @NonNull Size size, @NonNull ByteBuffer pixels, @IntRange(from = 0) long offset) throws IOException
From source file:com.almalence.opencam.SavingService.java
@TargetApi(21) private void saveDNGPicture(int frameNum, long sessionID, OutputStream os, int width, int height, int orientation, boolean cameraMirrored) { DngCreator creator = new DngCreator(CameraController.getCameraCharacteristics(), PluginManager.getInstance().getFromRAWCaptureResults("captureResult" + frameNum + sessionID)); byte[] frame = SwapHeap.SwapFromHeap( Integer.parseInt(getFromSharedMem("resultframe" + frameNum + Long.toString(sessionID))), Integer.parseInt(getFromSharedMem("resultframelen" + frameNum + Long.toString(sessionID)))); ByteBuffer buff = ByteBuffer.allocateDirect(frame.length); buff.put(frame);/*from w w w .j a va 2 s .com*/ int exif_orientation = ExifInterface.ORIENTATION_NORMAL; switch ((orientation + 360) % 360) { default: case 0: exif_orientation = ExifInterface.ORIENTATION_NORMAL; break; case 90: exif_orientation = cameraMirrored ? ExifInterface.ORIENTATION_ROTATE_270 : ExifInterface.ORIENTATION_ROTATE_90; break; case 180: exif_orientation = ExifInterface.ORIENTATION_ROTATE_180; break; case 270: exif_orientation = cameraMirrored ? ExifInterface.ORIENTATION_ROTATE_90 : ExifInterface.ORIENTATION_ROTATE_270; break; } try { creator.setOrientation(exif_orientation); creator.writeByteBuffer(os, new Size(width, height), buff, 0); } catch (IOException e) { creator.close(); e.printStackTrace(); Log.e("Open Camera", "saveDNGPicture error: " + e.getMessage()); } creator.close(); }