private static void writeDngBytesAndClose(Image image,TotalCaptureResult captureResult,CameraCharacteristics characteristics,File dngFile){
  try (DngCreator dngCreator=new DngCreator(characteristics,captureResult);FileOutputStream outputStream=new FileOutputStream(dngFile)){
    dngCreator.writeImage(outputStream,image);
    outputStream.close();
    image.close();
  }
 catch (  IOException e) {
    Log.e(TAG,"Could not store DNG file",e);
    return;
  }
  Log.i(TAG,"Successfully stored DNG file: " + dngFile.getAbsolutePath());
}

private static void writeDngBytesAndClose ( Image image , TotalCaptureResult captureResult , CameraCharacteristics characteristics , File dngFile ) { try ( DngCreator dngCreator = new DngCreator ( characteristics , captureResult ) ; FileOutputStream outputStream = new FileOutputStream ( dngFile ) ) { dngCreator . writeImage ( outputStream , image ) ; outputStream . close ( ) ; image . close ( ) ; } catch ( IOException e ) { Log . e ( TAG , "Could not store DNG file" , e ) ; return ; } Log . i ( TAG , "Successfully stored DNG file: " + dngFile . getAbsolutePath ( ) ) ; }
take the given raw image and capture result , convert it to a dng and write it to disk .
