ImageWriter.Builder
public
static
final
class
ImageWriter.Builder
extends Object
| java.lang.Object | |
| ↳ | android.media.ImageWriter.Builder |
Builder class for ImageWriter objects.
Summary
Public constructors | |
|---|---|
Builder(Surface surface)
Constructs a new builder for |
|
Public methods | |
|---|---|
ImageWriter
|
build()
Builds a new ImageWriter object. |
ImageWriter.Builder
|
setDataSpace(int dataSpace)
Set the dataspace of this ImageWriter. |
ImageWriter.Builder
|
setHardwareBufferFormat(int hardwareBufferFormat)
Set the hardwareBuffer format of this ImageWriter. |
ImageWriter.Builder
|
setImageFormat(int imageFormat)
Set the image format of this ImageWriter. |
ImageWriter.Builder
|
setMaxImages(int maxImages)
Set the maximum number of images. |
ImageWriter.Builder
|
setUsage(long usage)
Set the usage flag of this ImageWriter. |
ImageWriter.Builder
|
setWidthAndHeight(int width, int height)
Set the width and height of images. |
Inherited methods | |
|---|---|
Public constructors
Builder
public 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. |
| Throws | |
|---|---|
IllegalArgumentException |
if the surface is already abandoned. |
Public methods
build
public ImageWriter build ()
Builds a new ImageWriter object.
| Returns | |
|---|---|
ImageWriter |
The new ImageWriter object.
This value cannot be null. |
setDataSpace
public ImageWriter.Builder setDataSpace (int dataSpace)
Set the dataspace of this ImageWriter.
The default value is DataSpace.DATASPACE_UNKNOWN.
| Parameters | |
|---|---|
dataSpace |
int: The dataspace of the image that this writer will produce.
Value is either 0 or a combination of the following:
|
| Returns | |
|---|---|
ImageWriter.Builder |
the builder instance with customized dataspace value.
This value cannot be null. |
See also:
setHardwareBufferFormat
public ImageWriter.Builder setHardwareBufferFormat (int hardwareBufferFormat)
Set the hardwareBuffer format of this ImageWriter. The default value is
HardwareBuffer.RGBA_8888.
This function works together with setDataSpace(int) for an
ImageWriter instance. Setting at least one of these two replaces
setImageFormat(int) function.
| Parameters | |
|---|---|
hardwareBufferFormat |
int: The HardwareBuffer format of the image that this writer
will produce.
Value is one of the following:
|
| Returns | |
|---|---|
ImageWriter.Builder |
the Builder instance with customized buffer format.
This value cannot be null. |
See also:
setImageFormat
public ImageWriter.Builder setImageFormat (int imageFormat)
Set the image format of this ImageWriter. Default format depends on the Surface provided.
| Returns | |
|---|---|
ImageWriter.Builder |
the Builder instance with customized image format.
This value cannot be null. |
| Throws | |
|---|---|
IllegalArgumentException |
if imageFormat is invalid. |
setMaxImages
public ImageWriter.Builder setMaxImages (int maxImages)
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 |
| Returns | |
|---|---|
ImageWriter.Builder |
the Builder instance with customized usage value.
This value cannot be null. |
setUsage
public ImageWriter.Builder setUsage (long usage)
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.
| Parameters | |
|---|---|
usage |
long: The intended usage of the images produced by this ImageWriter.
Value is either 0 or a combination of the following:
|
| Returns | |
|---|---|
ImageWriter.Builder |
the Builder instance with customized usage flag.
This value cannot be null. |
See also:
setWidthAndHeight
public ImageWriter.Builder setWidthAndHeight (int width, int height)
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 |
| Returns | |
|---|---|
ImageWriter.Builder |
the Builder instance with customized width and height.
This value cannot be null. |