Compartilhar via


YuvImage.CompressToJpeg(Rect, Int32, Stream) Method

Definition

Compress a rectangle region in the YuvImage to a jpeg.

[Android.Runtime.Register("compressToJpeg", "(Landroid/graphics/Rect;ILjava/io/OutputStream;)Z", "GetCompressToJpeg_Landroid_graphics_Rect_ILjava_io_OutputStream_Handler")]
public virtual bool CompressToJpeg (Android.Graphics.Rect? rectangle, int quality, System.IO.Stream? stream);
[<Android.Runtime.Register("compressToJpeg", "(Landroid/graphics/Rect;ILjava/io/OutputStream;)Z", "GetCompressToJpeg_Landroid_graphics_Rect_ILjava_io_OutputStream_Handler")>]
abstract member CompressToJpeg : Android.Graphics.Rect * int * System.IO.Stream -> bool
override this.CompressToJpeg : Android.Graphics.Rect * int * System.IO.Stream -> bool

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
Int32

Hint to the compressor, 0-100. 0 meaning compress for small size, 100 meaning compress for max quality.

stream
Stream

OutputStream to write the compressed data.

Returns

True if the compression is successful.

Attributes

Exceptions

if rectangle is invalid; quality is not within [0, 100]; or stream is null.

Remarks

Compress a rectangle region in the YuvImage to a jpeg. For image format, only ImageFormat.NV21 and ImageFormat.YUY2 are supported. For color space, only SRGB is supported.

Java documentation for android.graphics.YuvImage.compressToJpeg(android.graphics.Rect, int, java.io.OutputStream).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to