Skip to content
com.iristick.smartglass.support.camera2

Class DngCreator

All Implemented Interfaces:
AutoCloseable

Deprecated. 
Not maintained anymore. Please use the com.iristick.smartglass.core.camera package instead.

@Deprecated
public abstract class DngCreator
extends Object
implements AutoCloseable
The DngCreator class provides functions to write raw pixel data as a DNG file.

This class is designed to be used with the ImageFormat.RAW_SENSOR buffers available from CameraDevice, or with Bayer-type raw pixel data that is otherwise generated by an application. The DNG metadata tags will be generated from a CaptureResult object or set directly.

The DNG file format is a cross-platform file format that is used to store pixel data from camera sensors with minimal pre-processing applied. DNG files allow for pixel data to be defined in a user-defined colorspace, and have associated metadata that allow for this pixel data to be converted to the standard CIE XYZ colorspace during post-processing.

For more information on the DNG file format and associated metadata, please refer to the Adobe DNG 1.4.0.0 specification.

Caution

The DngCreator does not support creating DNG files from CameraCharacteristics or CaptureResult objects that refer to an Iristick smartglass camera device.

Since:
Android API level 21

Field Summary

Modifier and Type Field and Description
static int MAX_THUMBNAIL_DIMENSION
Deprecated. 
Max width or height dimension for thumbnails.

Constructor Summary

Constructor and Description
DngCreator()
Deprecated. 
 

Method Summary

Modifier and Type Method and Description
static DngCreator create(CameraCharacteristics characteristics, CaptureResult metadata)
Deprecated. 
Create a new DNG object.
abstract DngCreator setDescription(String description)
Deprecated. 
Set the user description string to write.
abstract DngCreator setLocation(Location location)
Deprecated. 
Set image location metadata.
abstract DngCreator setOrientation(int orientation)
Deprecated. 
Set the orientation value to write.
abstract DngCreator setThumbnail(Bitmap pixels)
Deprecated. 
Set the thumbnail image.
abstract DngCreator setThumbnail(Image pixels)
Deprecated. 
Set the thumbnail image.
abstract void writeByteBuffer(OutputStream dngOutput, Size size, ByteBuffer pixels, long offset)
Deprecated. 
Write the ImageFormat.RAW_SENSOR pixel data to a DNG file with the currently configured metadata.
abstract void writeImage(OutputStream dngOutput, Image pixels)
Deprecated. 
Write the pixel data to a DNG file with the currently configured metadata.
abstract void writeInputStream(OutputStream dngOutput, Size size, InputStream pixels, long offset)
Deprecated. 
Write the ImageFormat.RAW_SENSOR pixel data to a DNG file with the currently configured metadata.

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface java.lang.AutoCloseable

close

Field Detail

MAX_THUMBNAIL_DIMENSION

public static final int MAX_THUMBNAIL_DIMENSION
Deprecated. 
Max width or height dimension for thumbnails.

Constructor Detail

DngCreator

public DngCreator()
Deprecated. 

Method Detail

create

public static DngCreator create(CameraCharacteristics characteristics,
                                CaptureResult metadata)
Deprecated. 
Create a new DNG object.

It is not necessary to call any set methods to write a well-formatted DNG file.

DNG metadata tags will be generated from the corresponding parameters in the CaptureResult object.

For best quality DNG files, it is strongly recommended that lens shading map output is enabled if supported. See CaptureRequest.STATISTICS_LENS_SHADING_MAP_MODE.

Parameters:
characteristics - an object containing the static CameraCharacteristics.
metadata - a metadata object to generate tags from.
Returns:
A new DngCreator instance.
Throws:
IllegalArgumentException - If either characteristics or metadata is null.
IllegalArgumentException - If the characteristics and metadata do not belong to the same device.
UnsupportedOperationException - If the underlying camera implementation does not support creating DNG files.

setOrientation

public abstract DngCreator setOrientation(int orientation)
Deprecated. 
Set the orientation value to write.

This will be written as the TIFF "Orientation" tag (0x0112). Calling this will override any prior settings for this tag.

Parameters:
orientation - the orientation value to set, one of:
Returns:
this DngCreator object.

setThumbnail

public abstract DngCreator setThumbnail(Bitmap pixels)
Deprecated. 
Set the thumbnail image.

Pixel data will be converted to a Baseline TIFF RGB image, with 8 bits per color channel. The alpha channel will be discarded. Thumbnail images with a dimension larger than MAX_THUMBNAIL_DIMENSION will be rejected.

Parameters:
pixels - a Bitmap of pixel data.
Returns:
this DngCreator object.
Throws:
IllegalArgumentException - if the given thumbnail image has a dimension larger than MAX_THUMBNAIL_DIMENSION.

setThumbnail

public abstract DngCreator setThumbnail(Image pixels)
Deprecated. 
Set the thumbnail image.

Pixel data is interpreted as a ImageFormat.YUV_420_888 image. Thumbnail images with a dimension larger than MAX_THUMBNAIL_DIMENSION will be rejected.

Parameters:
pixels - an Image object with the format ImageFormat.YUV_420_888.
Returns:
this DngCreator object.
Throws:
IllegalArgumentException - if the given thumbnail image has a dimension larger than MAX_THUMBNAIL_DIMENSION.

setLocation

public abstract DngCreator setLocation(Location location)
Deprecated. 
Set image location metadata.

The given location object must contain at least a valid time, latitude, and longitude (equivalent to the values returned by Location.getTime(), Location.getLatitude(), and Location.getLongitude() methods).

Parameters:
location - an Location object to set.
Returns:
this DngCreator object.
Throws:
IllegalArgumentException - if the given location object doesn't contain enough information to set location metadata.

setDescription

public abstract DngCreator setDescription(String description)
Deprecated. 
Set the user description string to write.

This is equivalent to setting the TIFF "ImageDescription" tag (0x010E).

Parameters:
description - the user description string.
Returns:
this DngCreator object.

writeInputStream

public abstract void writeInputStream(OutputStream dngOutput,
                                      Size size,
                                      InputStream pixels,
                                      long offset)
                               throws IOException
Deprecated. 
Write the ImageFormat.RAW_SENSOR pixel data to a DNG file with the currently configured metadata.

Raw pixel data must have 16 bits per pixel, and the input must contain at least offset + 2 * width * height) bytes. The width and height of the input are taken from the width and height set in the DngCreator metadata tags, and will typically be equal to the width and height of CameraCharacteristics.SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE. Prior to API level 23, this was always the same as CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE. The pixel layout in the input is determined from the reported color filter arrangement (CFA) set in CameraCharacteristics.SENSOR_INFO_COLOR_FILTER_ARRANGEMENT. If insufficient metadata is available to write a well-formatted DNG file, an IllegalStateException will be thrown.

Parameters:
dngOutput - an OutputStream to write the DNG file to.
size - the Size of the image to write, in pixels.
pixels - an InputStream of pixel data to write.
offset - the offset of the raw image in bytes. This indicates how many bytes will be skipped in the input before any pixel data is read.
Throws:
IOException - if an error was encountered in the input or output stream.
IllegalStateException - if not enough metadata information has been set to write a well-formatted DNG file.
IllegalArgumentException - if the size passed in does not match the

writeByteBuffer

public abstract void writeByteBuffer(OutputStream dngOutput,
                                     Size size,
                                     ByteBuffer pixels,
                                     long offset)
                              throws IOException
Deprecated. 
Write the ImageFormat.RAW_SENSOR pixel data to a DNG file with the currently configured metadata.

Raw pixel data must have 16 bits per pixel, and the input must contain at least offset + 2 * width * height) bytes. The width and height of the input are taken from the width and height set in the DngCreator metadata tags, and will typically be equal to the width and height of CameraCharacteristics.SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE. Prior to API level 23, this was always the same as CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE. The pixel layout in the input is determined from the reported color filter arrangement (CFA) set in CameraCharacteristics.SENSOR_INFO_COLOR_FILTER_ARRANGEMENT. If insufficient metadata is available to write a well-formatted DNG file, an IllegalStateException will be thrown.

Any mark or limit set on this ByteBuffer is ignored, and will be cleared by this method.

Parameters:
dngOutput - an OutputStream to write the DNG file to.
size - the Size of the image to write, in pixels.
pixels - an ByteBuffer of pixel data to write.
offset - the offset of the raw image in bytes. This indicates how many bytes will be skipped in the input before any pixel data is read.
Throws:
IOException - if an error was encountered in the input or output stream.
IllegalStateException - if not enough metadata information has been set to write a well-formatted DNG file.

writeImage

public abstract void writeImage(OutputStream dngOutput,
                                Image pixels)
                         throws IOException
Deprecated. 
Write the pixel data to a DNG file with the currently configured metadata.

For this method to succeed, the Image input must contain ImageFormat.RAW_SENSOR pixel data, otherwise an IllegalArgumentException will be thrown.

Parameters:
dngOutput - an OutputStream to write the DNG file to.
pixels - an Image to write.
Throws:
IOException - if an error was encountered in the output stream.
IllegalArgumentException - if an image with an unsupported format was used.
IllegalStateException - if not enough metadata information has been set to write a well-formatted DNG file.