Builder
class Builder
kotlin.Any | |
↳ | androidx.heifwriter.HeifWriter.Builder |
Builder class for constructing a HeifWriter object from specified parameters.
Summary
Public constructors | |
---|---|
Construct a Builder with output specified by its path. |
|
<init>(@NonNull fd: FileDescriptor, width: Int, height: Int, inputMode: Int) Construct a Builder with output specified by its file descriptor. |
Public methods | |
---|---|
HeifWriter! |
build() Build a HeifWriter object. |
HeifWriter.Builder! |
setGridEnabled(gridEnabled: Boolean) Set whether to enable grid option. |
HeifWriter.Builder! |
setHandler(@Nullable handler: Handler?) Provide a handler for the HeifWriter to use. |
HeifWriter.Builder! |
setMaxImages(maxImages: Int) Set the maximum number of images to write. |
HeifWriter.Builder! |
setPrimaryIndex(primaryIndex: Int) Set the primary image index. |
HeifWriter.Builder! |
setQuality(quality: Int) Set the quality for encoding images. |
HeifWriter.Builder! |
setRotation(rotation: Int) Set the image rotation in degrees. |
Public constructors
<init>
Builder(
@NonNull path: String,
width: Int,
height: Int,
inputMode: Int)
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 INPUT_MODE_BUFFER , INPUT_MODE_SURFACE , or INPUT_MODE_BITMAP . |
<init>
Builder(
@NonNull fd: FileDescriptor,
width: Int,
height: 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 |
Int: Width of the image. |
height |
Int: Height of the image. |
inputMode |
Int: Input mode for this writer, must be one of INPUT_MODE_BUFFER , INPUT_MODE_SURFACE , or INPUT_MODE_BITMAP . |
Public methods
build
fun build(): HeifWriter!
Build a HeifWriter object.
Return | |
---|---|
HeifWriter! |
a HeifWriter object built according to the specifications. |
Exceptions | |
---|---|
IOException |
if failed to create the writer, possibly due to failure to create android.media.MediaMuxer or android.media.MediaCodec . |
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. |
Return | |
---|---|
HeifWriter.Builder! |
this Builder object. |
setHandler
fun setHandler(@Nullable 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. |
Return | |
---|---|
HeifWriter.Builder! |
this Builder object. |
setMaxImages
fun setMaxImages(maxImages: Int): HeifWriter.Builder!
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 stop(long) , except for the input mode of INPUT_MODE_SURFACE , where the EOS timestamp must be specified (via setInputEndOfStreamTimestamp(long) and reached. Default is 1. |
Return | |
---|---|
HeifWriter.Builder! |
this Builder object. |
setPrimaryIndex
fun setPrimaryIndex(primaryIndex: Int): HeifWriter.Builder!
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. |
Return | |
---|---|
HeifWriter.Builder! |
this Builder object. |
setQuality
fun setQuality(quality: Int): HeifWriter.Builder!
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. |
Return | |
---|---|
HeifWriter.Builder! |
this Builder object. |
setRotation
fun setRotation(rotation: Int): HeifWriter.Builder!
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. |
Return | |
---|---|
HeifWriter.Builder! |
this Builder object. |