public class YuvImage extends Object
Constructor and Description |
---|
YuvImage(byte[] yuv,
int format,
int width,
int height,
int[] strides)
Construct an YuvImage.
|
Modifier and Type | Method and Description |
---|---|
boolean |
compressToJpeg(Rect rectangle,
int quality,
OutputStream stream)
Compress a rectangle region in the YuvImage to a jpeg.
|
int |
getHeight() |
int[] |
getStrides() |
int |
getWidth() |
byte[] |
getYuvData() |
int |
getYuvFormat() |
public YuvImage(byte[] yuv, int format, int width, int height, int[] strides)
yuv
- The YUV data. In the case of more than one image plane, all the planes must be
concatenated into a single byte array.format
- The YUV data format as defined in ImageFormat
.width
- The width of the YuvImage.height
- The height of the YuvImage.strides
- (Optional) Row bytes of each image plane. If yuv contains padding, the stride
of each image must be provided. If strides is null, the method assumes no
padding and derives the row bytes by format and width itself.IllegalArgumentException
- if format is not support; width or height <= 0; or yuv is
null.public boolean compressToJpeg(Rect rectangle, int quality, OutputStream stream)
rectangle
- The rectangle region to be compressed. The medthod checks if rectangle is
inside the image. Also, the method modifies rectangle if the chroma pixels
in it are not matched with the luma pixels in it.quality
- Hint to the compressor, 0-100. 0 meaning compress for
small size, 100 meaning compress for max quality.stream
- OutputStream to write the compressed data.IllegalArgumentException
- if rectangle is invalid; quality is not within [0,
100]; or stream is null.public byte[] getYuvData()
public int getYuvFormat()
ImageFormat
.public int[] getStrides()
public int getWidth()
public int getHeight()