Stay organized with collections
Save and categorize content based on your preferences.
Builder
class Builder
Builder class for ImageReader
objects.
Summary
Public constructors |
Constructs a new builder for ImageReader .
|
Public constructors
Builder
Builder(
width: Int,
height: Int)
Constructs a new builder for ImageReader
.
Parameters |
width |
Int: The default width in pixels that will be passed to the producer. May be overridden by the producer. Value is 1 or greater |
height |
Int: The default height in pixels that will be passed to the producer. May be overridden by the producer. Value is 1 or greater |
Public methods
build
fun build(): ImageReader
Builds a new ImageReader object.
Return |
ImageReader |
The new ImageReader object. This value cannot be null . |
setDefaultDataSpace
fun setDefaultDataSpace(dataSpace: Int): ImageReader.Builder
Set the default dataspace passed by the producer. May be overridden by the producer.
This function works together with setDefaultHardwareBufferFormat
for an ImageReader
instance. Setting at least one of these two replaces setImageFormat
function.
Parameters |
dataSpace |
Int: The dataspace of the image that this reader will produce. The default value is DataSpace.DATASPACE_UNKNOWN . Value is either 0 or a combination of android.hardware.DataSpace#DATASPACE_DEPTH , android.hardware.DataSpace#DATASPACE_DYNAMIC_DEPTH , android.hardware.DataSpace#DATASPACE_HEIF , android.hardware.DataSpace#DATASPACE_HEIF_ULTRAHDR , android.hardware.DataSpace#DATASPACE_JPEG_R , android.hardware.DataSpace#DATASPACE_UNKNOWN , android.hardware.DataSpace#DATASPACE_SCRGB_LINEAR , android.hardware.DataSpace#DATASPACE_SRGB , android.hardware.DataSpace#DATASPACE_SCRGB , android.hardware.DataSpace#DATASPACE_DISPLAY_P3 , android.hardware.DataSpace#DATASPACE_BT2020_HLG , android.hardware.DataSpace#DATASPACE_BT2020_PQ , android.hardware.DataSpace#DATASPACE_ADOBE_RGB , android.hardware.DataSpace#DATASPACE_JFIF , android.hardware.DataSpace#DATASPACE_BT601_625 , android.hardware.DataSpace#DATASPACE_BT601_525 , android.hardware.DataSpace#DATASPACE_BT2020 , android.hardware.DataSpace#DATASPACE_BT709 , android.hardware.DataSpace#DATASPACE_DCI_P3 , android.hardware.DataSpace#DATASPACE_SRGB_LINEAR , and android.hardware.DataSpace.DATASPACE_DISPLAY_BT2020 |
Return |
ImageReader.Builder |
the builder instance with customized dataspace value. This value cannot be null . |
fun setDefaultHardwareBufferFormat(hardwareBufferFormat: Int): ImageReader.Builder
Set the default hardwareBuffer format passed by the producer. May be overridden by the producer.
This function works together with setDefaultDataSpace
for an ImageReader
instance. Setting at least one of these two replaces setImageFormat
function.
The format of the Image can be overridden after setImageFormat
by calling this function and then setDefaultDataSpace
functions. Warning: Missing one of callings for initializing or overriding the format may involve undefined behaviors.
Parameters |
hardwareBufferFormat |
Int: The HardwareBuffer format of the image that this reader will produce. The default value is HardwareBuffer.RGBA_8888 . Value is android.hardware.HardwareBuffer#RGBA_8888 , android.hardware.HardwareBuffer#RGBA_FP16 , android.hardware.HardwareBuffer#RGBA_1010102 , android.hardware.HardwareBuffer#RGBX_8888 , android.hardware.HardwareBuffer#RGB_888 , android.hardware.HardwareBuffer#RGB_565 , android.hardware.HardwareBuffer#BLOB , android.hardware.HardwareBuffer#YCBCR_420_888 , android.hardware.HardwareBuffer#D_16 , android.hardware.HardwareBuffer#D_24 , android.hardware.HardwareBuffer#DS_24UI8 , android.hardware.HardwareBuffer#D_FP32 , android.hardware.HardwareBuffer#DS_FP32UI8 , android.hardware.HardwareBuffer#S_UI8 , android.hardware.HardwareBuffer#YCBCR_P010 , android.hardware.HardwareBuffer#YCBCR_P210 , android.hardware.HardwareBuffer#R_8 , android.hardware.HardwareBuffer#R_16 , android.hardware.HardwareBuffer#RG_1616 , or android.hardware.HardwareBuffer#RGBA_10101010 |
Return |
ImageReader.Builder |
the builder instance with customized hardwareBuffer value. This value cannot be null . |
fun setImageFormat(imageFormat: Int): ImageReader.Builder
Set the default image format passed by the producer. May be overridden by the producer.
setImageFormat
function replaces the combination of setDefaultHardwareBufferFormat
and setDefaultDataSpace
functions. Either this or these two functions must be called to initialize an ImageReader
instance.
Parameters |
imageFormat |
Int: The format of the image that this reader will produce. This must be one of the android.graphics.ImageFormat or android.graphics.PixelFormat constants. Note that not all formats are supported, like ImageFormat.NV21. The default value is ImageFormat.UNKNOWN . 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 |
ImageReader.Builder |
the builder instance with customized image format value. This value cannot be null . |
setMaxImages
fun setMaxImages(maxImages: Int): ImageReader.Builder
Set the maximal number of images.
Parameters |
maxImages |
Int: The maximum number of images the user will want to access simultaneously. This should be as small as possible to limit memory use. Default value is 1. |
Return |
ImageReader.Builder |
the Builder instance with customized usage value. This value cannot be null . |
setUsage
fun setUsage(usage: Long): ImageReader.Builder
Set the consumer usage flag.
Parameters |
usage |
Long: The intended usage of the images consumed by this ImageReader. See the usages on HardwareBuffer for a list of valid usage bits. Default value is HardwareBuffer.USAGE_CPU_READ_OFTEN . Value is either 0 or a combination of android.hardware.HardwareBuffer#USAGE_CPU_READ_RARELY , android.hardware.HardwareBuffer#USAGE_CPU_READ_OFTEN , android.hardware.HardwareBuffer#USAGE_CPU_WRITE_RARELY , android.hardware.HardwareBuffer#USAGE_CPU_WRITE_OFTEN , android.hardware.HardwareBuffer#USAGE_GPU_SAMPLED_IMAGE , android.hardware.HardwareBuffer#USAGE_GPU_COLOR_OUTPUT , android.hardware.HardwareBuffer#USAGE_COMPOSER_OVERLAY , android.hardware.HardwareBuffer#USAGE_PROTECTED_CONTENT , android.hardware.HardwareBuffer#USAGE_VIDEO_ENCODE , android.hardware.HardwareBuffer#USAGE_GPU_DATA_BUFFER , android.hardware.HardwareBuffer#USAGE_SENSOR_DIRECT_DATA , android.hardware.HardwareBuffer#USAGE_GPU_CUBE_MAP , android.hardware.HardwareBuffer#USAGE_GPU_MIPMAP_COMPLETE , and android.hardware.HardwareBuffer#USAGE_FRONT_BUFFER |
Return |
ImageReader.Builder |
the Builder instance with customized usage value. This value cannot be null . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-13 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-13 UTC."],[],[]]