android.hardware.camera2.DngCreator Java Examples

The following examples show how to use android.hardware.camera2.DngCreator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OneCameraImpl.java    From Camera2 with Apache License 2.0 6 votes vote down vote up
/**
 * Take the given RAW image and capture result, convert it to a DNG and
 * write it to disk.
 *
 * @param image           the image containing the 16-bit RAW data (RAW_SENSOR)
 * @param captureResult   the capture result for the image
 * @param characteristics the camera characteristics of the camera that took
 *                        the RAW image
 * @param dngFile         the destination to where the resulting DNG data is written
 *                        to
 */
private static void writeDngBytesAndClose(Image image, TotalCaptureResult captureResult, CameraCharacteristics
        characteristics, File dngFile)
{
    try (DngCreator dngCreator = new DngCreator(characteristics, captureResult); FileOutputStream outputStream =
            new FileOutputStream(dngFile))
    {
        // TODO: Add DngCreator#setThumbnail and add the DNG to the normal
        // filmstrip.
        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());
}