Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
added in version 1.0.0
belongs to Maven artifact androidx.heifwriter:heifwriter:1.0.0-rc01

HeifWriter.Builder

public static final class HeifWriter.Builder
extends Object

java.lang.Object
   ↳ androidx.heifwriter.HeifWriter.Builder


Builder class for constructing a HeifWriter object from specified parameters.

Summary

Public constructors

HeifWriter.Builder(String path, int width, int height, int inputMode)

Construct a Builder with output specified by its path.

HeifWriter.Builder(FileDescriptor fd, int width, int height, int inputMode)

Construct a Builder with output specified by its file descriptor.

Public methods

HeifWriter build()

Build a HeifWriter object.

HeifWriter.Builder setGridEnabled(boolean gridEnabled)

Set whether to enable grid option.

HeifWriter.Builder setHandler(Handler handler)

Provide a handler for the HeifWriter to use.

HeifWriter.Builder setMaxImages(int maxImages)

Set the maximum number of images to write.

HeifWriter.Builder setPrimaryIndex(int primaryIndex)

Set the primary image index.

HeifWriter.Builder setQuality(int quality)

Set the quality for encoding images.

HeifWriter.Builder setRotation(int rotation)

Set the image rotation in degrees.

Inherited methods

Public constructors

HeifWriter.Builder

added in version 1.0.0
public HeifWriter.Builder (String path, 
                int width, 
                int height, 
                int inputMode)

Construct a Builder with output specified by its path.

Parameters
path String: Path of the file to be written.

width int: Width of the image.

height int: Height of the image.

inputMode int: Input mode for this writer, must be one of HeifWriter.INPUT_MODE_BUFFER, HeifWriter.INPUT_MODE_SURFACE, or HeifWriter.INPUT_MODE_BITMAP.

HeifWriter.Builder

added in version 1.0.0
public HeifWriter.Builder (FileDescriptor fd, 
                int width, 
                int height, 
                int inputMode)

Construct a Builder with output specified by its file descriptor.

Parameters
fd FileDescriptor: File descriptor of the file to be written.

width int: Width of the image.

height int: Height of the image.

inputMode int: Input mode for this writer, must be one of HeifWriter.INPUT_MODE_BUFFER, HeifWriter.INPUT_MODE_SURFACE, or HeifWriter.INPUT_MODE_BITMAP.

Public methods

build

added in version 1.0.0
public HeifWriter build ()

Build a HeifWriter object.

Returns
HeifWriter a HeifWriter object built according to the specifications.

Throws
IOException if failed to create the writer, possibly due to failure to create MediaMuxer or MediaCodec.

setGridEnabled

added in version 1.0.0
public HeifWriter.Builder setGridEnabled (boolean gridEnabled)

Set whether to enable grid option.

Parameters
gridEnabled boolean: Whether to enable grid option. If enabled, the tile size will be automatically chosen. Default is to enable.

Returns
HeifWriter.Builder this Builder object.

setHandler

added in version 1.0.0
public HeifWriter.Builder setHandler (Handler handler)

Provide a handler for the HeifWriter to use.

Parameters
handler Handler: If not null, client will receive all callbacks on the handler's looper. Otherwise, client will receive callbacks on a looper created by the writer. Default is null.

Returns
HeifWriter.Builder this Builder object.

setMaxImages

added in version 1.0.0
public HeifWriter.Builder setMaxImages (int maxImages)

Set the maximum number of images to write.

Parameters
maxImages int: Max number of images to write. Frames exceeding this number will not be written to file. The writing can be stopped earlier before this number of images are written by HeifWriter.stop(long), except for the input mode of HeifWriter.INPUT_MODE_SURFACE, where the EOS timestamp must be specified (via HeifWriter.setInputEndOfStreamTimestamp(long) and reached. Default is 1.

Returns
HeifWriter.Builder this Builder object.

setPrimaryIndex

added in version 1.0.0
public HeifWriter.Builder setPrimaryIndex (int primaryIndex)

Set the primary image index.

Parameters
primaryIndex int: Index of the image that should be marked as primary, must be within range [0, maxImages - 1] inclusive. Default is 0.

Returns
HeifWriter.Builder this Builder object.

setQuality

added in version 1.0.0
public HeifWriter.Builder setQuality (int quality)

Set the quality for encoding images.

Parameters
quality int: A number between 0 and 100 (inclusive), with 100 indicating the best quality supported by this implementation. Default is 100.

Returns
HeifWriter.Builder this Builder object.

setRotation

added in version 1.0.0
public HeifWriter.Builder setRotation (int rotation)

Set the image rotation in degrees.

Parameters
rotation int: Rotation angle (clockwise) of the image, must be 0, 90, 180 or 270. Default is 0.

Returns
HeifWriter.Builder this Builder object.