Class Overview
YuvImage contains YUV data and provides a method that compresses a region of
the YUV data to a Jpeg. The YUV data should be provided as a single byte
array irrespective of the number of image planes in it.
Currently only ImageFormat.NV21 and ImageFormat.YUY2 are supported.
To compress a rectangle region in the YUV data, users have to specify the
region by left, top, width and height.
Summary
Public Constructors |
|
YuvImage(byte[] yuv, int format, int width, int height, int[] strides)
Construct an YuvImage.
|
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals(Object o)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
final
void
|
wait(long millis, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long millis)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
|
Public Constructors
public
YuvImage
(byte[] yuv, int format, int width, int height, int[] strides)
Parameters
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. |
Public Methods
public
boolean
compressToJpeg
(Rect rectangle, int quality, OutputStream stream)
Compress a rectangle region in the YuvImage to a jpeg.
Only ImageFormat.NV21 and ImageFormat.YUY2
are supported for now.
Parameters
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. |
Returns
- True if the compression is successful.
public
int[]
getStrides
()
Returns
- the number of row bytes in each image plane.
public
byte[]
getYuvData
()
public
int
getYuvFormat
()