Builder
class Builder
kotlin.Any | |
↳ | android.media.ImageWriter.Builder |
Builder class for ImageWriter
objects.
Summary
Public constructors | |
---|---|
Constructs a new builder for |
Public methods | |
---|---|
ImageWriter |
build() Builds a new ImageWriter object. |
ImageWriter.Builder |
setDataSpace(dataSpace: Int) Set the dataspace of this ImageWriter. |
ImageWriter.Builder |
setHardwareBufferFormat(hardwareBufferFormat: Int) Set the hardwareBuffer format of this ImageWriter. |
ImageWriter.Builder |
setImageFormat(imageFormat: Int) Set the image format of this ImageWriter. |
ImageWriter.Builder |
setMaxImages(maxImages: Int) Set the maximum number of images. |
ImageWriter.Builder |
Set the usage flag of this ImageWriter. |
ImageWriter.Builder |
setWidthAndHeight(width: Int, height: Int) Set the width and height of images. |
Public constructors
Builder
Builder(surface: Surface)
Constructs a new builder for ImageWriter
.
Parameters | |
---|---|
surface |
Surface: The destination Surface this writer produces Image data into. This value cannot be null . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if the surface is already abandoned. |
Public methods
build
fun build(): ImageWriter
Builds a new ImageWriter object.
Return | |
---|---|
ImageWriter |
The new ImageWriter object. This value cannot be null . |
setDataSpace
fun setDataSpace(dataSpace: Int): ImageWriter.Builder
Set the dataspace of this ImageWriter. The default value is DataSpace#DATASPACE_UNKNOWN
.
Return | |
---|---|
ImageWriter.Builder |
the builder instance with customized dataspace value. This value cannot be null . |
See Also
setHardwareBufferFormat
fun setHardwareBufferFormat(hardwareBufferFormat: Int): ImageWriter.Builder
Set the hardwareBuffer format of this ImageWriter. The default value is HardwareBuffer.RGBA_8888
.
This function works together with setDataSpace
for an ImageWriter
instance. Setting at least one of these two replaces setImageFormat
function.
Return | |
---|---|
ImageWriter.Builder |
the Builder instance with customized buffer format. This value cannot be null . |
See Also
setImageFormat
fun setImageFormat(imageFormat: Int): ImageWriter.Builder
Set the image format of this ImageWriter. Default format depends on the Surface provided.
Return | |
---|---|
ImageWriter.Builder |
the Builder instance with customized image format. This value cannot be null . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if imageFormat is invalid. |
setMaxImages
fun setMaxImages(maxImages: Int): ImageWriter.Builder
Set the maximum number of images. Default value is 1.
Parameters | |
---|---|
maxImages |
Int: The maximum number of Images the user will want to access simultaneously for producing Image data. Value is 1 or greater |
Return | |
---|---|
ImageWriter.Builder |
the Builder instance with customized usage value. This value cannot be null . |
setUsage
fun setUsage(usage: Long): ImageWriter.Builder
Set the usage flag of this ImageWriter.
If this function is not called, usage bit will be set to HardwareBuffer#USAGE_CPU_WRITE_OFTEN
if the image format is not PRIVATE
.
Return | |
---|---|
ImageWriter.Builder |
the Builder instance with customized usage flag. This value cannot be null . |
See Also
setWidthAndHeight
fun setWidthAndHeight(
width: Int,
height: Int
): ImageWriter.Builder
Set the width and height of images. Default size is dependent on the Surface that is provided by the downstream end-point.
Parameters | |
---|---|
width |
Int: The width in pixels that will be passed to the producer. Value is 1 or greater |
height |
Int: The height in pixels that will be passed to the producer. Value is 1 or greater |
Return | |
---|---|
ImageWriter.Builder |
the Builder instance with customized width and height. This value cannot be null . |