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 ImageReader.

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

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public constructors

Builder

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

Added in API level 33
public ImageReader build ()

Builds a new ImageReader object.

Returns
ImageReader The new ImageReader object. This value cannot be null.

setDefaultDataSpace

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

Returns
ImageReader.Builder the builder instance with customized dataspace value. This value cannot be null.

setDefaultHardwareBufferFormat

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

Returns
ImageReader.Builder the builder instance with customized hardwareBuffer value. This value cannot be null.

setImageFormat

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

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

Added in API level 33
public ImageReader.Builder setUsage (long usage)

Set the consumer usage flag.

Returns
ImageReader.Builder the Builder instance with customized usage value. This value cannot be null.

See also: