YuvImage
public class YuvImage
extends Object
YuvImage包含YUV数据并提供了一种将YUV数据的区域压缩为Jpeg的方法。 YUV数据应该作为单字节数组提供,而不管其中的图像平面的数量如何。 目前只支持ImageFormat.NV21和ImageFormat.YUY2。 要压缩YUV数据中的矩形区域,用户必须按左,顶部,宽度和高度指定区域。
Summary
Public constructors |
YuvImage(byte[] yuv, int format, int width, int height, int[] strides) 构建一个YuvImage。 |
Public constructors
YuvImage
YuvImage (byte[] yuv,
int format,
int width,
int height,
int[] strides)
构建一个YuvImage。
Parameters |
yuv |
byte : The YUV data. In the case of more than one image plane, all the planes must be concatenated into a single byte array. |
format |
int : The YUV data format as defined in ImageFormat . |
width |
int : The width of the YuvImage. |
height |
int : The height of the YuvImage. |
strides |
int : (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. |
Public methods
compressToJpeg
boolean compressToJpeg (Rect rectangle,
int quality,
OutputStream stream)
将YuvImage中的矩形区域压缩为jpeg。 目前只支持ImageFormat.NV21和ImageFormat.YUY2。
Parameters |
rectangle |
Rect : 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 |
int : Hint to the compressor, 0-100. 0 meaning compress for small size, 100 meaning compress for max quality. |
stream |
OutputStream : OutputStream to write the compressed data. |
Returns |
boolean |
True if the compression is successful. |
getHeight
int getHeight ()
Returns |
int |
the height of the image. |
getStrides
int[] getStrides ()
Returns |
int[] |
the number of row bytes in each image plane. |
getWidth
int getWidth ()
Returns |
int |
the width of the image. |
getYuvData
byte[] getYuvData ()
Returns |
byte[] |
the YUV data. |
getYuvFormat
int getYuvFormat ()