createScaledBitmap
@NonNull
Return a scaled bitmap.
This algorithm is intended for downscaling by large ratios when high quality is desired. It is similar to the creation of mipmaps, but stops at the desired size. Visually, the result is smoother and softer than createScaledBitmap
The returned bitmap will always be a mutable copy with a config matching the input except in the following scenarios:
- The source bitmap is returned and the source bitmap is immutable.
- The source bitmap is a
HARDWARE
bitmap. For this input, a mutable non-HARDWARE
Bitmap is returned. On API 31 and up, the internal format of the HardwareBuffer is read to determine the underlying format, and the returned Bitmap will use a Config to match. Pre-31, the returned Bitmap will beARGB_8888
.
Return
A new bitmap in the requested size.
Parameters
srcBm
A source bitmap. It will not be altered.
dstW
The output width
dstH
The output height
srcRect
Uses a region of the input bitmap as the source.
scaleInLinearSpace
When true, uses LINEAR_EXTENDED_SRGB
as a color space when scaling. Otherwise, uses the color space of the input bitmap. (On API level 26 and earlier, this parameter has no effect).