BitmapCompat
class BitmapCompat
Helper for accessing features in Bitmap.
Summary
Public functions |
|
|---|---|
java-static Bitmap |
createScaledBitmap(Return a scaled bitmap. |
java-static Int |
@ReplaceWith(expression = "bitmap.getAllocationByteCount()")This function is deprecated. Call |
java-static Boolean |
@ReplaceWith(expression = "bitmap.hasMipMap()")This function is deprecated. Call |
java-static Unit |
@ReplaceWith(expression = "bitmap.setHasMipMap(hasMipMap)")This function is deprecated. Call setHasMipMap directly. |
Public functions
createScaledBitmap
java-static fun createScaledBitmap(
srcBm: Bitmap,
dstW: Int,
dstH: Int,
srcRect: Rect?,
scaleInLinearSpace: Boolean
): Bitmap
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
HARDWAREbitmap. For this input, a mutable non-HARDWAREBitmap 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.
| Parameters | |
|---|---|
srcBm: Bitmap |
A source bitmap. It will not be altered. |
dstW: Int |
The output width |
dstH: Int |
The output height |
srcRect: Rect? |
Uses a region of the input bitmap as the source. |
scaleInLinearSpace: Boolean |
When true, uses |
| Returns | |
|---|---|
Bitmap |
A new bitmap in the requested size. |
@ReplaceWith(expression = "bitmap.getAllocationByteCount()")
java-static fungetAllocationByteCount(bitmap: Bitmap): Int
Returns the size of the allocated memory used to store this bitmap's pixels.
This value will not change over the lifetime of a Bitmap.
| See also | |
|---|---|
getAllocationByteCount |
@ReplaceWith(expression = "bitmap.hasMipMap()")
java-static funhasMipMap(bitmap: Bitmap): Boolean
Indicates whether the renderer responsible for drawing this bitmap should attempt to use mipmaps when this bitmap is drawn scaled down.
If you know that you are going to draw this bitmap at less than 50% of its original size, you may be able to obtain a higher quality
This property is only a suggestion that can be ignored by the renderer. It is not guaranteed to have any effect.
| Returns | |
|---|---|
Boolean |
true if the renderer should attempt to use mipmaps, false otherwise |
| See also | |
|---|---|
hasMipMap |
@ReplaceWith(expression = "bitmap.setHasMipMap(hasMipMap)")
java-static funsetHasMipMap(bitmap: Bitmap, hasMipMap: Boolean): Unit
Set a hint for the renderer responsible for drawing this bitmap indicating that it should attempt to use mipmaps when this bitmap is drawn scaled down.
If you know that you are going to draw this bitmap at less than 50% of its original size, you may be able to obtain a higher quality by turning this property on.
Note that if the renderer respects this hint it might have to allocate extra memory to hold the mipmap levels for this bitmap.
This property is only a suggestion that can be ignored by the renderer. It is not guaranteed to have any effect.
| Parameters | |
|---|---|
bitmap: Bitmap |
bitmap for which to set the state. |
hasMipMap: Boolean |
indicates whether the renderer should attempt to use mipmaps |
| See also | |
|---|---|
setHasMipMap |