Sdílet prostřednictvím


ImageDecoder.SetTargetSampleSize(Int32) Method

Definition

Set the target size with a sampleSize.

[Android.Runtime.Register("setTargetSampleSize", "(I)V", "", ApiSince=28)]
public void SetTargetSampleSize (int sampleSize);
[<Android.Runtime.Register("setTargetSampleSize", "(I)V", "", ApiSince=28)>]
member this.SetTargetSampleSize : int -> unit

Parameters

sampleSize
Int32

sampling rate of the encoded image.

Attributes

Remarks

Set the target size with a sampleSize.

By default, the output size will match the size of the encoded image, which can be retrieved from the ImageInfo ImageInfo in OnHeaderDecodedListener#onHeaderDecoded onHeaderDecoded.

Requests the decoder to subsample the original image, returning a smaller image to save memory. The sampleSize is the number of pixels in either dimension that correspond to a single pixel in the output. For example, sampleSize == 4 returns an image that is 1/4 the width/height of the original, and 1/16 the number of pixels.

Must be greater than or equal to 1.

This has the same effect as calling #setTargetSize with dimensions based on the sampleSize. Unlike dividing the original width and height by the sampleSize manually, calling this method allows ImageDecoder to round in the direction that it can do most efficiently.

Only the last call to this or #setTargetSize is respected.

Like all setters on ImageDecoder, this must be called inside OnHeaderDecodedListener#onHeaderDecoded onHeaderDecoded.

Java documentation for android.graphics.ImageDecoder.setTargetSampleSize(int).

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