public final class Downsampler extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Downsampler.DecodeCallbacks
Callbacks for key points during decodes.
|
Modifier and Type | Field and Description |
---|---|
static Option<DecodeFormat> |
DECODE_FORMAT
Indicates the
DecodeFormat that will be used in conjunction
with the image format to determine the Bitmap.Config to provide to
BitmapFactory.Options.inPreferredConfig when decoding the image. |
static Option<DownsampleStrategy> |
DOWNSAMPLE_STRATEGY
Indicates the
DownsampleStrategy option that
will be used to calculate the sample size to use to downsample an image given the original
and target dimensions of the image. |
static Option<Boolean> |
FIX_BITMAP_SIZE_TO_REQUESTED_DIMENSIONS
Ensure that the size of the bitmap is fixed to the requested width and height of the
resource from the caller.
|
Constructor and Description |
---|
Downsampler(List<ImageHeaderParser> parsers,
DisplayMetrics displayMetrics,
BitmapPool bitmapPool,
ArrayPool byteArrayPool) |
Modifier and Type | Method and Description |
---|---|
Resource<Bitmap> |
decode(InputStream is,
int outWidth,
int outHeight,
Options options)
Returns a Bitmap decoded from the given
InputStream that is rotated to match any EXIF
data present in the stream and that is downsampled according to the given dimensions and any
provided DownsampleStrategy option. |
Resource<Bitmap> |
decode(InputStream is,
int requestedWidth,
int requestedHeight,
Options options,
Downsampler.DecodeCallbacks callbacks)
Returns a Bitmap decoded from the given
InputStream that is rotated to match any EXIF
data present in the stream and that is downsampled according to the given dimensions and any
provided DownsampleStrategy option. |
boolean |
handles(ByteBuffer byteBuffer) |
boolean |
handles(InputStream is) |
public static final Option<DecodeFormat> DECODE_FORMAT
DecodeFormat
that will be used in conjunction
with the image format to determine the Bitmap.Config
to provide to
BitmapFactory.Options.inPreferredConfig
when decoding the image.public static final Option<DownsampleStrategy> DOWNSAMPLE_STRATEGY
DownsampleStrategy
option that
will be used to calculate the sample size to use to downsample an image given the original
and target dimensions of the image.public static final Option<Boolean> FIX_BITMAP_SIZE_TO_REQUESTED_DIMENSIONS
public Downsampler(List<ImageHeaderParser> parsers, DisplayMetrics displayMetrics, BitmapPool bitmapPool, ArrayPool byteArrayPool)
public boolean handles(InputStream is)
public boolean handles(ByteBuffer byteBuffer)
public Resource<Bitmap> decode(InputStream is, int outWidth, int outHeight, Options options) throws IOException
InputStream
that is rotated to match any EXIF
data present in the stream and that is downsampled according to the given dimensions and any
provided DownsampleStrategy
option.IOException
decode(InputStream, int, int, Options, DecodeCallbacks)
public Resource<Bitmap> decode(InputStream is, int requestedWidth, int requestedHeight, Options options, Downsampler.DecodeCallbacks callbacks) throws IOException
InputStream
that is rotated to match any EXIF
data present in the stream and that is downsampled according to the given dimensions and any
provided DownsampleStrategy
option.
If a Bitmap is present in the
BitmapPool
whose dimensions exactly match
those of the image for the given InputStream is available, the operation is much less expensive
in terms of memory.
The provided InputStream
must return true
from
InputStream.markSupported()
and is expected to support a reasonably large
mark limit to accommodate reading large image headers (~5MB).
is
- An InputStream
to the data for the image.requestedWidth
- The width the final image should be close to.requestedHeight
- The height the final image should be close to.options
- A set of options that may contain one or more supported options that influence
how a Bitmap will be decoded from the given stream.callbacks
- A set of callbacks allowing callers to optionally respond to various
significant events during the decode process.IOException