HeifWriter.Builder
class HeifWriter.Builder
Builder class for constructing a HeifWriter object from specified parameters.
Summary
Public constructors |
|---|
Builder(Construct a Builder with output specified by its file descriptor. |
Builder(Construct a Builder with output specified by its path. |
Public functions |
|
|---|---|
HeifWriter |
build()Build a HeifWriter object. |
HeifWriter.Builder |
setEncoderPreference(preference: EncoderPreference)Sets the encoder preference for this builder. |
HeifWriter.Builder |
setGridEnabled(gridEnabled: Boolean)Set whether to enable grid option. |
HeifWriter.Builder |
setHandler(handler: Handler?)Provide a handler for the HeifWriter to use. |
HeifWriter.Builder |
setMaxImages(maxImages: @IntRange(from = 1) Int)Set the maximum number of images to write. |
HeifWriter.Builder |
setPrimaryIndex(primaryIndex: @IntRange(from = 0) Int)Set the primary image index. |
HeifWriter.Builder |
setQuality(quality: @IntRange(from = 0, to = 100) Int)Set the quality for encoding images. |
HeifWriter.Builder |
setRotation(rotation: @IntRange(from = 0) Int)Set the image rotation in degrees. |
Public constructors
Builder
Builder(
fd: FileDescriptor,
width: @IntRange(from = 1) Int,
height: @IntRange(from = 1) Int,
inputMode: Int
)
Construct a Builder with output specified by its file descriptor.
| Parameters | |
|---|---|
fd: FileDescriptor |
File descriptor of the file to be written. |
width: @IntRange(from = 1) Int |
Width of the image in number of pixels. |
height: @IntRange(from = 1) Int |
Height of the image in number of pixels. |
inputMode: Int |
Input mode for this writer, must be one of |
Builder
Builder(
path: String,
width: @IntRange(from = 1) Int,
height: @IntRange(from = 1) Int,
inputMode: Int
)
Construct a Builder with output specified by its path.
| Parameters | |
|---|---|
path: String |
Path of the file to be written. |
width: @IntRange(from = 1) Int |
Width of the image in number of pixels. |
height: @IntRange(from = 1) Int |
Height of the image in number of pixels. |
inputMode: Int |
Input mode for this writer, must be one of |
Public functions
build
fun build(): HeifWriter
Build a HeifWriter object.
| Returns | |
|---|---|
HeifWriter |
a HeifWriter object built according to the specifications. |
| Throws | |
|---|---|
java.io.IOException |
if failed to create the writer, possibly due to failure to create |
setEncoderPreference
fun setEncoderPreference(preference: EncoderPreference): HeifWriter.Builder
Sets the encoder preference for this builder.
This method allows you to configure the desired encoding type (hardware or software) and the bitrate mode (e.g., constant quality).
| Parameters | |
|---|---|
preference: EncoderPreference |
The non-null |
| Returns | |
|---|---|
HeifWriter.Builder |
This |
setGridEnabled
fun setGridEnabled(gridEnabled: Boolean): HeifWriter.Builder
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
fun setHandler(handler: Handler?): HeifWriter.Builder
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
fun setMaxImages(maxImages: @IntRange(from = 1) Int): HeifWriter.Builder
Set the maximum number of images to write.
| Parameters | |
|---|---|
maxImages: @IntRange(from = 1) 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 |
| Returns | |
|---|---|
HeifWriter.Builder |
this Builder object. |
setPrimaryIndex
fun setPrimaryIndex(primaryIndex: @IntRange(from = 0) Int): HeifWriter.Builder
Set the primary image index.
| Parameters | |
|---|---|
primaryIndex: @IntRange(from = 0) 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
fun setQuality(quality: @IntRange(from = 0, to = 100) Int): HeifWriter.Builder
Set the quality for encoding images.
| Parameters | |
|---|---|
quality: @IntRange(from = 0, to = 100) 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
fun setRotation(rotation: @IntRange(from = 0) Int): HeifWriter.Builder
Set the image rotation in degrees.
| Parameters | |
|---|---|
rotation: @IntRange(from = 0) Int |
Rotation angle in degrees (clockwise) of the image, must be 0, 90, 180 or 270. Default is 0. |
| Returns | |
|---|---|
HeifWriter.Builder |
this Builder object. |