Added in API level 33

Builder


class Builder
kotlin.Any
   ↳ android.media.ImageWriter.Builder

Builder class for ImageWriter objects.

Summary

Public constructors
Builder(surface: Surface)

Constructs a new builder for ImageWriter.

Public methods
ImageWriter

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
setUsage(usage: Long)

Set the usage flag of this ImageWriter.

ImageWriter.Builder
setWidthAndHeight(width: Int, height: Int)

Set the width and height of images.

Public constructors

Builder

Added in API level 33
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

Added in API level 33
fun build(): ImageWriter

Builds a new ImageWriter object.

Return
ImageWriter The new ImageWriter object. This value cannot be null.

setImageFormat

Added in API level 33
fun setImageFormat(imageFormat: Int): ImageWriter.Builder

Set the image format of this ImageWriter. Default format depends on the Surface provided.

Parameters
imageFormat Int: The format of the ImageWriter. It can be any valid specified by ImageFormat or PixelFormat. Value is android.graphics.ImageFormat#UNKNOWN, android.graphics.PixelFormat#RGBA_8888, android.graphics.PixelFormat#RGBX_8888, android.graphics.PixelFormat#RGB_888, android.graphics.ImageFormat#RGB_565, android.graphics.ImageFormat#YV12, android.graphics.ImageFormat#Y8, android.graphics.ImageFormat.Y16, android.graphics.ImageFormat#YCBCR_P010, android.graphics.ImageFormat#YCBCR_P210, android.graphics.ImageFormat#NV16, android.graphics.ImageFormat#NV21, android.graphics.ImageFormat#YUY2, android.graphics.ImageFormat#JPEG, android.graphics.ImageFormat#DEPTH_JPEG, android.graphics.ImageFormat#YUV_420_888, android.graphics.ImageFormat#YUV_422_888, android.graphics.ImageFormat#YUV_444_888, android.graphics.ImageFormat#FLEX_RGB_888, android.graphics.ImageFormat#FLEX_RGBA_8888, android.graphics.ImageFormat#RAW_SENSOR, android.graphics.ImageFormat#RAW_PRIVATE, android.graphics.ImageFormat#RAW10, android.graphics.ImageFormat#RAW12, android.graphics.ImageFormat#DEPTH16, android.graphics.ImageFormat#DEPTH_POINT_CLOUD, android.graphics.ImageFormat.RAW_DEPTH, android.graphics.ImageFormat.RAW_DEPTH10, android.graphics.ImageFormat#PRIVATE, android.graphics.ImageFormat#HEIC, android.graphics.ImageFormat.HEIC_ULTRAHDR, or android.graphics.ImageFormat#JPEG_R
Return
ImageWriter.Builder the Builder instance with customized image format. This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if imageFormat is invalid.

setMaxImages

Added in API level 33
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.

setWidthAndHeight

Added in API level 33
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.