AvifWriter.Builder
public final class AvifWriter.Builder
Builder class for constructing a AvifWriter 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 methods |
|
|---|---|
@NonNull AvifWriter |
build()Build a AvifWriter object. |
@NonNull AvifWriter.Builder |
setEncoderPreference(@NonNull EncoderPreference preference)Sets the encoder preference for this builder. |
@NonNull AvifWriter.Builder |
setGridEnabled(boolean gridEnabled)Set whether to enable grid option. |
@NonNull AvifWriter.Builder |
setHandler(@Nullable Handler handler)Provide a handler for the AvifWriter to use. |
@NonNull AvifWriter.Builder |
setHighBitDepthEnabled(boolean highBitDepthEnabled)Provide a setting for the AvifWriter to use high bit-depth or not. |
@NonNull AvifWriter.Builder |
setMaxImages(@IntRange(from = 1) int maxImages)Set the maximum number of images to write. |
@NonNull AvifWriter.Builder |
setPrimaryIndex(@IntRange(from = 0) int primaryIndex)Set the primary image index. |
@NonNull AvifWriter.Builder |
setQuality(@IntRange(from = 0, to = 100) int quality)Set the quality for encoding images. |
@NonNull AvifWriter.Builder |
setRotation(@IntRange(from = 0) int rotation)Set the image rotation in degrees. |
Public constructors
Builder
public Builder(
@NonNull FileDescriptor fd,
@IntRange(from = 1) int width,
@IntRange(from = 1) int height,
int inputMode
)
Construct a Builder with output specified by its file descriptor.
| Parameters | |
|---|---|
@NonNull FileDescriptor fd |
File descriptor of the file to be written. |
@IntRange(from = 1) int width |
Width of the image in number of pixels. |
@IntRange(from = 1) int height |
Height of the image in number of pixels. |
int inputMode |
Input mode for this writer, must be one of |
Builder
public Builder(
@NonNull String path,
@IntRange(from = 1) int width,
@IntRange(from = 1) int height,
int inputMode
)
Construct a Builder with output specified by its path.
| Parameters | |
|---|---|
@NonNull String path |
Path of the file to be written. |
@IntRange(from = 1) int width |
Width of the image in number of pixels. |
@IntRange(from = 1) int height |
Height of the image in number of pixels. |
int inputMode |
Input mode for this writer, must be one of |
Public methods
build
public @NonNull AvifWriter build()
Build a AvifWriter object.
| Returns | |
|---|---|
@NonNull AvifWriter |
a AvifWriter object built according to the specifications. |
| Throws | |
|---|---|
java.io.IOException |
if failed to create the writer, possibly due to failure to create |
setEncoderPreference
public @NonNull AvifWriter.Builder setEncoderPreference(@NonNull EncoderPreference preference)
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 | |
|---|---|
@NonNull EncoderPreference preference |
The non-null |
| Returns | |
|---|---|
@NonNull AvifWriter.Builder |
This |
setGridEnabled
public @NonNull AvifWriter.Builder setGridEnabled(boolean gridEnabled)
Set whether to enable grid option.
| Parameters | |
|---|---|
boolean gridEnabled |
Whether to enable grid option. If enabled, the tile size will be automatically chosen. Default is to enable. |
| Returns | |
|---|---|
@NonNull AvifWriter.Builder |
this Builder object. |
setHandler
public @NonNull AvifWriter.Builder setHandler(@Nullable Handler handler)
Provide a handler for the AvifWriter to use.
| Parameters | |
|---|---|
@Nullable 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 | |
|---|---|
@NonNull AvifWriter.Builder |
this Builder object. |
setHighBitDepthEnabled
public @NonNull AvifWriter.Builder setHighBitDepthEnabled(boolean highBitDepthEnabled)
Provide a setting for the AvifWriter to use high bit-depth or not.
| Parameters | |
|---|---|
boolean highBitDepthEnabled |
Whether to enable high bit-depth mode. Default is false, if true, AvifWriter will encode with high bit-depth. |
| Returns | |
|---|---|
@NonNull AvifWriter.Builder |
this Builder object. |
setMaxImages
public @NonNull AvifWriter.Builder setMaxImages(@IntRange(from = 1) int maxImages)
Set the maximum number of images to write.
| Parameters | |
|---|---|
@IntRange(from = 1) int maxImages |
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 | |
|---|---|
@NonNull AvifWriter.Builder |
this Builder object. |
setPrimaryIndex
public @NonNull AvifWriter.Builder setPrimaryIndex(@IntRange(from = 0) int primaryIndex)
Set the primary image index.
| Parameters | |
|---|---|
@IntRange(from = 0) int primaryIndex |
Index of the image that should be marked as primary, must be within range [0, maxImages - 1] inclusive. Default is 0. |
| Returns | |
|---|---|
@NonNull AvifWriter.Builder |
this Builder object. |
setQuality
public @NonNull AvifWriter.Builder setQuality(@IntRange(from = 0, to = 100) int quality)
Set the quality for encoding images.
| Parameters | |
|---|---|
@IntRange(from = 0, to = 100) int quality |
A number between 0 and 100 (inclusive), with 100 indicating the best quality supported by this implementation. Default is 100. |
| Returns | |
|---|---|
@NonNull AvifWriter.Builder |
this Builder object. |
setRotation
public @NonNull AvifWriter.Builder setRotation(@IntRange(from = 0) int rotation)
Set the image rotation in degrees.
| Parameters | |
|---|---|
@IntRange(from = 0) int rotation |
Rotation angle in degrees (clockwise) of the image, must be 0, 90, 180 or 270. Default is 0. |
| Returns | |
|---|---|
@NonNull AvifWriter.Builder |
this Builder object. |