ImageReader.Builder
public
static
final
class
ImageReader.Builder
extends Object
java.lang.Object | |
↳ | android.media.ImageReader.Builder |
Builder class for ImageReader
objects.
Summary
Public constructors | |
---|---|
Builder(int width, int height)
Constructs a new builder for |
Public methods | |
---|---|
ImageReader
|
build()
Builds a new ImageReader object. |
ImageReader.Builder
|
setDefaultDataSpace(int dataSpace)
Set the default dataspace passed by the producer. |
ImageReader.Builder
|
setDefaultHardwareBufferFormat(int hardwareBufferFormat)
Set the default hardwareBuffer format passed by the producer. |
ImageReader.Builder
|
setImageFormat(int imageFormat)
Set the default image format passed by the producer. |
ImageReader.Builder
|
setMaxImages(int maxImages)
Set the maximal number of images. |
ImageReader.Builder
|
setUsage(long usage)
Set the consumer usage flag. |
Inherited methods | |
---|---|
Public constructors
Builder
public Builder (int width, int height)
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 |
See also:
Public methods
build
public ImageReader build ()
Builds a new ImageReader object.
Returns | |
---|---|
ImageReader |
The new ImageReader object.
This value cannot be null . |
setDefaultDataSpace
public ImageReader.Builder setDefaultDataSpace (int dataSpace)
Set the default dataspace passed by the producer. May be overridden by the producer.
This function works together with setDefaultHardwareBufferFormat(int)
for an
ImageReader
instance. Setting at least one of these two replaces
setImageFormat(int)
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 DataSpace.DATASPACE_DEPTH , DataSpace.DATASPACE_DYNAMIC_DEPTH , DataSpace.DATASPACE_HEIF , android.hardware.DataSpace.DATASPACE_HEIF_ULTRAHDR, DataSpace.DATASPACE_JPEG_R , DataSpace.DATASPACE_UNKNOWN , DataSpace.DATASPACE_SCRGB_LINEAR , DataSpace.DATASPACE_SRGB , DataSpace.DATASPACE_SCRGB , DataSpace.DATASPACE_DISPLAY_P3 , DataSpace.DATASPACE_BT2020_HLG , DataSpace.DATASPACE_BT2020_PQ , DataSpace.DATASPACE_ADOBE_RGB , DataSpace.DATASPACE_JFIF , DataSpace.DATASPACE_BT601_625 , DataSpace.DATASPACE_BT601_525 , DataSpace.DATASPACE_BT2020 , DataSpace.DATASPACE_BT709 , DataSpace.DATASPACE_DCI_P3 , DataSpace.DATASPACE_SRGB_LINEAR , and android.hardware.DataSpace.DATASPACE_DISPLAY_BT2020 |
Returns | |
---|---|
ImageReader.Builder |
the builder instance with customized dataspace value.
This value cannot be null . |
See also:
setDefaultHardwareBufferFormat
public ImageReader.Builder setDefaultHardwareBufferFormat (int hardwareBufferFormat)
Set the default hardwareBuffer format passed by the producer. May be overridden by the producer.
This function works together with setDefaultDataSpace(int)
for an
ImageReader
instance. Setting at least one of these two replaces
setImageFormat(int)
function.
The format of the Image can be overridden after setImageFormat(int)
by calling
this function and then setDefaultDataSpace(int)
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 HardwareBuffer.RGBA_8888 , HardwareBuffer.RGBA_FP16 , HardwareBuffer.RGBA_1010102 , HardwareBuffer.RGBX_8888 , HardwareBuffer.RGB_888 , HardwareBuffer.RGB_565 , HardwareBuffer.BLOB , HardwareBuffer.YCBCR_420_888 , HardwareBuffer.D_16 , HardwareBuffer.D_24 , HardwareBuffer.DS_24UI8 , HardwareBuffer.D_FP32 , HardwareBuffer.DS_FP32UI8 , HardwareBuffer.S_UI8 , HardwareBuffer.YCBCR_P010 , HardwareBuffer.YCBCR_P210 , HardwareBuffer.R_8 , HardwareBuffer.R_16 , HardwareBuffer.RG_1616 , or HardwareBuffer.RGBA_10101010 |
Returns | |
---|---|
ImageReader.Builder |
the builder instance with customized hardwareBuffer value.
This value cannot be null . |
setImageFormat
public ImageReader.Builder setImageFormat (int imageFormat)
Set the default image format passed by the producer. May be overridden by the producer.
setImageFormat(int)
function replaces the combination of
setDefaultHardwareBufferFormat(int)
and setDefaultDataSpace(int)
functions.
Either this or these two functions must be called to initialize an ImageReader
instance.
Returns | |
---|---|
ImageReader.Builder |
the builder instance with customized image format value.
This value cannot be null . |
setMaxImages
public ImageReader.Builder setMaxImages (int maxImages)
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. |
Returns | |
---|---|
ImageReader.Builder |
the Builder instance with customized usage value.
This value cannot be null . |
setUsage
public ImageReader.Builder setUsage (long usage)
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 HardwareBuffer.USAGE_CPU_READ_RARELY , HardwareBuffer.USAGE_CPU_READ_OFTEN , HardwareBuffer.USAGE_CPU_WRITE_RARELY , HardwareBuffer.USAGE_CPU_WRITE_OFTEN , HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE , HardwareBuffer.USAGE_GPU_COLOR_OUTPUT , HardwareBuffer.USAGE_COMPOSER_OVERLAY , HardwareBuffer.USAGE_PROTECTED_CONTENT , HardwareBuffer.USAGE_VIDEO_ENCODE , HardwareBuffer.USAGE_GPU_DATA_BUFFER , HardwareBuffer.USAGE_SENSOR_DIRECT_DATA , HardwareBuffer.USAGE_GPU_CUBE_MAP , HardwareBuffer.USAGE_GPU_MIPMAP_COMPLETE , and HardwareBuffer.USAGE_FRONT_BUFFER |
Returns | |
---|---|
ImageReader.Builder |
the Builder instance with customized usage value.
This value cannot be null . |
See also: