Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/graphics/Bitmap#constants) \| [Inherited Constants](https://developer.android.com/reference/android/graphics/Bitmap#inhconstants) \| [Fields](https://developer.android.com/reference/android/graphics/Bitmap#lfields) \| [Methods](https://developer.android.com/reference/android/graphics/Bitmap#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/graphics/Bitmap#inhmethods)

# Bitmap

*** ** * ** ***


`
public

final

class
Bitmap
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/android/os/Parcelable


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.graphics.Bitmap |

<br />

*** ** * ** ***

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/graphics/Bitmap#DENSITY_NONE` Indicates that the bitmap was created for an unknown pixel density. |

| ### Inherited constants |
|---|
| From interface `https://developer.android.com/reference/android/os/Parcelable` |---|---| | `int` | `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` Descriptor bit used with `https://developer.android.com/reference/android/os/Parcelable#describeContents()`: indicates that the Parcelable object's flattened representation includes a file descriptor. | | `int` | `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` Flag for use with `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`: the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`". | |

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/os/Parcelable.Creator<https://developer.android.com/reference/android/graphics/Bitmap>` | `https://developer.android.com/reference/android/graphics/Bitmap#CREATOR` |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#asShared()() ` Return an immutable bitmap backed by shared memory which can be efficiently passed between processes via Parcelable. |
| ` boolean` | ` https://developer.android.com/reference/android/graphics/Bitmap#compress(android.graphics.Bitmap.CompressFormat,%20int,%20java.io.OutputStream)(https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat format, int quality, https://developer.android.com/reference/java/io/OutputStream stream) ` Write a compressed version of the bitmap to the specified outputstream. |
| ` https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#copy(android.graphics.Bitmap.Config,%20boolean)(https://developer.android.com/reference/android/graphics/Bitmap.Config config, boolean isMutable) ` Tries to make a new bitmap based on the dimensions of this bitmap, setting the new bitmap's config to the one specified, and then copying this bitmap's pixels into the new bitmap. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#copyPixelsFromBuffer(java.nio.Buffer)(https://developer.android.com/reference/java/nio/Buffer src) ` <br /> Copy the pixels from the buffer, beginning at the current position, overwriting the bitmap's pixels. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#copyPixelsToBuffer(java.nio.Buffer)(https://developer.android.com/reference/java/nio/Buffer dst) ` <br /> Copy the bitmap's pixels into the specified buffer (allocated by the caller). |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(android.graphics.Bitmap,%20int,%20int,%20int,%20int)(https://developer.android.com/reference/android/graphics/Bitmap source, int x, int y, int width, int height) ` Returns a bitmap from the specified subset of the source bitmap. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(int[],%20int,%20int,%20android.graphics.Bitmap.Config)(int[] colors, int width, int height, https://developer.android.com/reference/android/graphics/Bitmap.Config config) ` Returns a immutable bitmap with the specified width and height, with each pixel value set to the corresponding value in the colors array. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(android.graphics.Bitmap,%20int,%20int,%20int,%20int,%20android.graphics.Matrix,%20boolean)(https://developer.android.com/reference/android/graphics/Bitmap source, int x, int y, int width, int height, https://developer.android.com/reference/android/graphics/Matrix m, boolean filter) ` Returns a bitmap from subset of the source bitmap, transformed by the optional matrix. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(android.util.DisplayMetrics,%20int,%20int,%20android.graphics.Bitmap.Config,%20boolean,%20android.graphics.ColorSpace)(https://developer.android.com/reference/android/util/DisplayMetrics display, int width, int height, https://developer.android.com/reference/android/graphics/Bitmap.Config config, boolean hasAlpha, https://developer.android.com/reference/android/graphics/ColorSpace colorSpace) ` Returns a mutable bitmap with the specified width and height. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(android.graphics.Bitmap)(https://developer.android.com/reference/android/graphics/Bitmap src) ` Returns a bitmap from the source bitmap. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(android.graphics.Picture)(https://developer.android.com/reference/android/graphics/Picture source) ` Creates a Bitmap from the given `https://developer.android.com/reference/android/graphics/Picture` source of recorded drawing commands. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(android.util.DisplayMetrics,%20int[],%20int,%20int,%20int,%20int,%20android.graphics.Bitmap.Config)(https://developer.android.com/reference/android/util/DisplayMetrics display, int[] colors, int offset, int stride, int width, int height, https://developer.android.com/reference/android/graphics/Bitmap.Config config) ` Returns a immutable bitmap with the specified width and height, with each pixel value set to the corresponding value in the colors array. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(android.util.DisplayMetrics,%20int[],%20int,%20int,%20android.graphics.Bitmap.Config)(https://developer.android.com/reference/android/util/DisplayMetrics display, int[] colors, int width, int height, https://developer.android.com/reference/android/graphics/Bitmap.Config config) ` Returns a immutable bitmap with the specified width and height, with each pixel value set to the corresponding value in the colors array. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(android.util.DisplayMetrics,%20int,%20int,%20android.graphics.Bitmap.Config)(https://developer.android.com/reference/android/util/DisplayMetrics display, int width, int height, https://developer.android.com/reference/android/graphics/Bitmap.Config config) ` Returns a mutable bitmap with the specified width and height. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(int[],%20int,%20int,%20int,%20int,%20android.graphics.Bitmap.Config)(int[] colors, int offset, int stride, int width, int height, https://developer.android.com/reference/android/graphics/Bitmap.Config config) ` Returns a immutable bitmap with the specified width and height, with each pixel value set to the corresponding value in the colors array. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(android.graphics.Picture,%20int,%20int,%20android.graphics.Bitmap.Config)(https://developer.android.com/reference/android/graphics/Picture source, int width, int height, https://developer.android.com/reference/android/graphics/Bitmap.Config config) ` Creates a Bitmap from the given `https://developer.android.com/reference/android/graphics/Picture` source of recorded drawing commands. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(int,%20int,%20android.graphics.Bitmap.Config,%20boolean,%20android.graphics.ColorSpace)(int width, int height, https://developer.android.com/reference/android/graphics/Bitmap.Config config, boolean hasAlpha, https://developer.android.com/reference/android/graphics/ColorSpace colorSpace) ` Returns a mutable bitmap with the specified width and height. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(android.util.DisplayMetrics,%20int,%20int,%20android.graphics.Bitmap.Config,%20boolean)(https://developer.android.com/reference/android/util/DisplayMetrics display, int width, int height, https://developer.android.com/reference/android/graphics/Bitmap.Config config, boolean hasAlpha) ` Returns a mutable bitmap with the specified width and height. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(int,%20int,%20android.graphics.Bitmap.Config)(int width, int height, https://developer.android.com/reference/android/graphics/Bitmap.Config config) ` Returns a mutable bitmap with the specified width and height. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(int,%20int,%20android.graphics.Bitmap.Config,%20boolean)(int width, int height, https://developer.android.com/reference/android/graphics/Bitmap.Config config, boolean hasAlpha) ` Returns a mutable bitmap with the specified width and height. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#createScaledBitmap(android.graphics.Bitmap,%20int,%20int,%20boolean)(https://developer.android.com/reference/android/graphics/Bitmap src, int dstWidth, int dstHeight, boolean filter) ` Creates a new bitmap, scaled from an existing bitmap, when possible. |
| ` int` | ` https://developer.android.com/reference/android/graphics/Bitmap#describeContents()() ` No special parcel contents. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#eraseColor(int)(int c) ` Fills the bitmap's pixels with the specified `https://developer.android.com/reference/android/graphics/Color`. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#eraseColor(long)(long color) ` Fills the bitmap's pixels with the specified `ColorLong`. |
| ` https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#extractAlpha()() ` Returns a new bitmap that captures the alpha values of the original. |
| ` https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#extractAlpha(android.graphics.Paint,%20int[])(https://developer.android.com/reference/android/graphics/Paint paint, int[] offsetXY) ` Returns a new bitmap that captures the alpha values of the original. |
| ` int` | ` https://developer.android.com/reference/android/graphics/Bitmap#getAllocationByteCount()() ` Returns the size of the allocated memory used to store this bitmap's pixels. |
| ` int` | ` https://developer.android.com/reference/android/graphics/Bitmap#getByteCount()() ` Returns the minimum number of bytes that can be used to store this bitmap's pixels. |
| ` https://developer.android.com/reference/android/graphics/Color` | ` https://developer.android.com/reference/android/graphics/Bitmap#getColor(int,%20int)(int x, int y) ` Returns the `https://developer.android.com/reference/android/graphics/Color` at the specified location. |
| ` https://developer.android.com/reference/android/graphics/ColorSpace` | ` https://developer.android.com/reference/android/graphics/Bitmap#getColorSpace()() ` Returns the color space associated with this bitmap. |
| ` https://developer.android.com/reference/android/graphics/Bitmap.Config` | ` https://developer.android.com/reference/android/graphics/Bitmap#getConfig()() ` If the bitmap's internal config is in one of the public formats, return that config, otherwise return null. |
| ` int` | ` https://developer.android.com/reference/android/graphics/Bitmap#getDensity()() ` <br /> Returns the density for this bitmap. |
| ` https://developer.android.com/reference/android/graphics/Gainmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#getGainmap()() ` Returns the gainmap or null if the bitmap doesn't contain a gainmap |
| ` int` | ` https://developer.android.com/reference/android/graphics/Bitmap#getGenerationId()() ` Returns the generation ID of this bitmap. |
| ` https://developer.android.com/reference/android/hardware/HardwareBuffer` | ` https://developer.android.com/reference/android/graphics/Bitmap#getHardwareBuffer()() ` |
| ` int` | ` https://developer.android.com/reference/android/graphics/Bitmap#getHeight()() ` Returns the bitmap's height |
| ` byte[]` | ` https://developer.android.com/reference/android/graphics/Bitmap#getNinePatchChunk()() ` Returns an optional array of private data, used by the UI system for some bitmaps. |
| ` int` | ` https://developer.android.com/reference/android/graphics/Bitmap#getPixel(int,%20int)(int x, int y) ` Returns the `https://developer.android.com/reference/android/graphics/Color` at the specified location. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#getPixels(int[],%20int,%20int,%20int,%20int,%20int,%20int)(int[] pixels, int offset, int stride, int x, int y, int width, int height) ` Returns in pixels\[\] a copy of the data in the bitmap. |
| ` int` | ` https://developer.android.com/reference/android/graphics/Bitmap#getRowBytes()() ` Return the number of bytes between rows in the bitmap's pixels. |
| ` int` | ` https://developer.android.com/reference/android/graphics/Bitmap#getScaledHeight(int)(int targetDensity) ` Convenience method that returns the height of this bitmap divided by the density scale factor. |
| ` int` | ` https://developer.android.com/reference/android/graphics/Bitmap#getScaledHeight(android.graphics.Canvas)(https://developer.android.com/reference/android/graphics/Canvas canvas) ` Convenience for calling `https://developer.android.com/reference/android/graphics/Bitmap#getScaledHeight(int)` with the target density of the given `https://developer.android.com/reference/android/graphics/Canvas`. |
| ` int` | ` https://developer.android.com/reference/android/graphics/Bitmap#getScaledHeight(android.util.DisplayMetrics)(https://developer.android.com/reference/android/util/DisplayMetrics metrics) ` Convenience for calling `https://developer.android.com/reference/android/graphics/Bitmap#getScaledHeight(int)` with the target density of the given `https://developer.android.com/reference/android/util/DisplayMetrics`. |
| ` int` | ` https://developer.android.com/reference/android/graphics/Bitmap#getScaledWidth(int)(int targetDensity) ` Convenience method that returns the width of this bitmap divided by the density scale factor. |
| ` int` | ` https://developer.android.com/reference/android/graphics/Bitmap#getScaledWidth(android.util.DisplayMetrics)(https://developer.android.com/reference/android/util/DisplayMetrics metrics) ` Convenience for calling `https://developer.android.com/reference/android/graphics/Bitmap#getScaledWidth(int)` with the target density of the given `https://developer.android.com/reference/android/util/DisplayMetrics`. |
| ` int` | ` https://developer.android.com/reference/android/graphics/Bitmap#getScaledWidth(android.graphics.Canvas)(https://developer.android.com/reference/android/graphics/Canvas canvas) ` Convenience for calling `https://developer.android.com/reference/android/graphics/Bitmap#getScaledWidth(int)` with the target density of the given `https://developer.android.com/reference/android/graphics/Canvas`. |
| ` int` | ` https://developer.android.com/reference/android/graphics/Bitmap#getWidth()() ` Returns the bitmap's width |
| ` boolean` | ` https://developer.android.com/reference/android/graphics/Bitmap#hasAlpha()() ` Returns true if the bitmap's config supports per-pixel alpha, and if the pixels may contain non-opaque alpha values. |
| ` boolean` | ` https://developer.android.com/reference/android/graphics/Bitmap#hasGainmap()() ` Returns whether or not this Bitmap contains a Gainmap. |
| ` boolean` | ` https://developer.android.com/reference/android/graphics/Bitmap#hasMipMap()() ` Indicates whether the renderer responsible for drawing this bitmap should attempt to use mipmaps when this bitmap is drawn scaled down. |
| ` boolean` | ` https://developer.android.com/reference/android/graphics/Bitmap#isMutable()() ` Returns true if the bitmap is marked as mutable (i.e. can be drawn into) |
| ` boolean` | ` https://developer.android.com/reference/android/graphics/Bitmap#isPremultiplied()() ` <br /> Indicates whether pixels stored in this bitmaps are stored pre-multiplied. |
| ` boolean` | ` https://developer.android.com/reference/android/graphics/Bitmap#isRecycled()() ` Returns true if this bitmap has been recycled. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#prepareToDraw()() ` Builds caches associated with the bitmap that are used for drawing it. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#reconfigure(int,%20int,%20android.graphics.Bitmap.Config)(int width, int height, https://developer.android.com/reference/android/graphics/Bitmap.Config config) ` <br /> Modifies the bitmap to have a specified width, height, and `https://developer.android.com/reference/android/graphics/Bitmap.Config`, without affecting the underlying allocation backing the bitmap. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#recycle()() ` Immediately releases the pixel data associated with this Bitmap. |
| ` boolean` | ` https://developer.android.com/reference/android/graphics/Bitmap#sameAs(android.graphics.Bitmap)(https://developer.android.com/reference/android/graphics/Bitmap other) ` Given another bitmap, return true if it has the same dimensions, config, and pixel data as this bitmap. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#setColorSpace(android.graphics.ColorSpace)(https://developer.android.com/reference/android/graphics/ColorSpace colorSpace) ` <br /> Modifies the bitmap to have the specified `https://developer.android.com/reference/android/graphics/ColorSpace`, without affecting the underlying allocation backing the bitmap. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#setConfig(android.graphics.Bitmap.Config)(https://developer.android.com/reference/android/graphics/Bitmap.Config config) ` <br /> Convenience method for calling `https://developer.android.com/reference/android/graphics/Bitmap#reconfigure(int,%20int,%20android.graphics.Bitmap.Config)` with the current height and width. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#setDensity(int)(int density) ` <br /> Specifies the density for this bitmap. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#setGainmap(android.graphics.Gainmap)(https://developer.android.com/reference/android/graphics/Gainmap gainmap) ` Sets a gainmap on this bitmap, or removes the gainmap if null |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#setHasAlpha(boolean)(boolean hasAlpha) ` Tell the bitmap if all of the pixels are known to be opaque (false) or if some of the pixels may contain non-opaque alpha values (true). |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#setHasMipMap(boolean)(boolean hasMipMap) ` 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. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#setHeight(int)(int height) ` <br /> Convenience method for calling `https://developer.android.com/reference/android/graphics/Bitmap#reconfigure(int,%20int,%20android.graphics.Bitmap.Config)` with the current width and config. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#setPixel(int,%20int,%20int)(int x, int y, int color) ` <br /> Write the specified `https://developer.android.com/reference/android/graphics/Color` into the bitmap (assuming it is mutable) at the x,y coordinate. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#setPixels(int[],%20int,%20int,%20int,%20int,%20int,%20int)(int[] pixels, int offset, int stride, int x, int y, int width, int height) ` <br /> Replace pixels in the bitmap with the colors in the array. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#setPremultiplied(boolean)(boolean premultiplied) ` Sets whether the bitmap should treat its data as pre-multiplied. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#setWidth(int)(int width) ` <br /> Convenience method for calling `https://developer.android.com/reference/android/graphics/Bitmap#reconfigure(int,%20int,%20android.graphics.Bitmap.Config)` with the current height and config. |
| ` static https://developer.android.com/reference/android/graphics/Bitmap` | ` https://developer.android.com/reference/android/graphics/Bitmap#wrapHardwareBuffer(android.hardware.HardwareBuffer,%20android.graphics.ColorSpace)(https://developer.android.com/reference/android/hardware/HardwareBuffer hardwareBuffer, https://developer.android.com/reference/android/graphics/ColorSpace colorSpace) ` Create a hardware bitmap backed by a `https://developer.android.com/reference/android/hardware/HardwareBuffer`. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Bitmap#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel p, int flags) ` Write the bitmap and its pixels to the parcel. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||
| From interface ` https://developer.android.com/reference/android/os/Parcelable ` |---|---| | ` abstract int` | ` https://developer.android.com/reference/android/os/Parcelable#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. | | ` abstract void` | ` https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Flatten this object in to a Parcel. | ||

## Constants

### DENSITY_NONE

Added in [API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int DENSITY_NONE
```

Indicates that the bitmap was created for an unknown pixel density.

<br />

**See also:**

- `https://developer.android.com/reference/android/graphics/Bitmap#getDensity()`
- `https://developer.android.com/reference/android/graphics/Bitmap#setDensity(int)`

Constant Value:

0
(0x00000000)


## Fields

### CREATOR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final Creator<Bitmap> CREATOR
```

<br />

<br />

## Public methods

### asShared

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Bitmap asShared ()
```

Return an immutable bitmap backed by shared memory which can be
efficiently passed between processes via Parcelable.

If this bitmap already meets these criteria it will return itself.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value cannot be `null`. <br /> |

### compress

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean compress (Bitmap.CompressFormat format, 
                int quality, 
                OutputStream stream)
```

Write a compressed version of the bitmap to the specified outputstream.
If this returns true, the bitmap can be reconstructed by passing a
corresponding inputstream to BitmapFactory.decodeStream(). Note: not
all Formats support all bitmap configs directly, so it is possible that
the returned bitmap from BitmapFactory could be in a different bitdepth,
and/or may have lost per-pixel alpha (e.g. JPEG only supports opaque
pixels).


This method may take several seconds to complete, so it should
only be called from a worker thread.

<br />

| Parameters ||
|---|---|
| `format` | `Bitmap.CompressFormat`: The format of the compressed image. This value cannot be `null`. <br /> |
| `quality` | `int`: Hint to the compressor, 0-100. The value is interpreted differently depending on the `https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat`. <br /> |
| `stream` | `OutputStream`: The outputstream to write the compressed data. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | true if successfully compressed to the specified stream. <br /> |

### copy

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Bitmap copy (Bitmap.Config config, 
                boolean isMutable)
```

Tries to make a new bitmap based on the dimensions of this bitmap,
setting the new bitmap's config to the one specified, and then copying
this bitmap's pixels into the new bitmap. If the conversion is not
supported, or the allocator fails, then this returns NULL. The returned
bitmap has the same density and color space as the original, except in
the following cases. When copying to `https://developer.android.com/reference/android/graphics/Bitmap.Config#ALPHA_8`, the color
space is dropped. When copying to or from `https://developer.android.com/reference/android/graphics/Bitmap.Config#RGBA_F16`,
EXTENDED or non-EXTENDED variants may be adjusted as appropriate.

<br />

| Parameters ||
|---|---|
| `config` | `Bitmap.Config`: The desired config for the resulting bitmap. This value cannot be `null`. <br /> |
| `isMutable` | `boolean`: True if the resulting bitmap should be mutable (i.e. its pixels can be modified) <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | the new bitmap, or null if the copy could not be made. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if config is `https://developer.android.com/reference/android/graphics/Bitmap.Config#HARDWARE` and isMutable is true |

### copyPixelsFromBuffer

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void copyPixelsFromBuffer (Buffer src)
```

<br />

Copy the pixels from the buffer, beginning at the current position,
overwriting the bitmap's pixels. The data in the buffer is not changed
in any way (unlike setPixels(), which converts from unpremultipled 32bit
to whatever the bitmap's native format is. The pixels in the source
buffer are assumed to be in the bitmap's color space.

The data in the buffer must be packed according to the Bitmap's `https://developer.android.com/reference/android/graphics/Bitmap.Config`.
See `https://developer.android.com/reference/android/graphics/Bitmap.Config` for the packing formulas for each configuration.

After this method returns, the current position of the buffer is
updated: the position is incremented by the number of elements read from
the buffer. If you need to read the bitmap from the buffer again you must
first rewind the buffer.

<br />

<br />

| Parameters ||
|---|---|
| `src` | `Buffer`: This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if the bitmap's config is `https://developer.android.com/reference/android/graphics/Bitmap.Config#HARDWARE` |

### copyPixelsToBuffer

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void copyPixelsToBuffer (Buffer dst)
```

<br />

Copy the bitmap's pixels into the specified buffer (allocated by the
caller). An exception is thrown if the buffer is not large enough to
hold all of the pixels (taking into account the number of bytes per
pixel) or if the Buffer subclass is not one of the support types
(ByteBuffer, ShortBuffer, IntBuffer).

The data copied into the buffer is packed according to the Bitmap's `https://developer.android.com/reference/android/graphics/Bitmap.Config`.
See `https://developer.android.com/reference/android/graphics/Bitmap.Config` for the packing formulas for each configuration.

The content of the bitmap is copied into the buffer as-is. This means
that if this bitmap stores its pixels pre-multiplied
(see `https://developer.android.com/reference/android/graphics/Bitmap#isPremultiplied()`, the values in the buffer will also be
pre-multiplied. The pixels remain in the color space of the bitmap.

After this method returns, the current position of the buffer is
updated: the position is incremented by the number of elements written
in the buffer.

<br />

<br />

| Parameters ||
|---|---|
| `dst` | `Buffer`: This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if the bitmap's config is `https://developer.android.com/reference/android/graphics/Bitmap.Config#HARDWARE` |

### createBitmap

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap createBitmap (Bitmap source, 
                int x, 
                int y, 
                int width, 
                int height)
```

Returns a bitmap from the specified subset of the source
bitmap. The new bitmap may be the same object as source, or a copy may
have been made. It is initialized with the same density and color space
as the original bitmap.

<br />

| Parameters ||
|---|---|
| `source` | `Bitmap`: The bitmap we are subsetting. This value cannot be `null`. <br /> |
| `x` | `int`: The x coordinate of the first pixel in source <br /> |
| `y` | `int`: The y coordinate of the first pixel in source <br /> |
| `width` | `int`: The number of pixels in each row <br /> |
| `height` | `int`: The number of rows <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | A copy of a subset of the source bitmap or the source bitmap itself. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the x, y, width, height values are outside of the dimensions of the source bitmap, or width is \<= 0, or height is \<= 0 |

### createBitmap

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap createBitmap (int[] colors, 
                int width, 
                int height, 
                Bitmap.Config config)
```

Returns a immutable bitmap with the specified width and height, with each
pixel value set to the corresponding value in the colors array. Its
initial density is as per `https://developer.android.com/reference/android/graphics/Bitmap#getDensity()`. The newly created
bitmap is in the `https://developer.android.com/reference/android/graphics/ColorSpace.Named#SRGB` color space.

<br />

| Parameters ||
|---|---|
| `colors` | `int`: Array of sRGB `https://developer.android.com/reference/android/graphics/Color` used to initialize the pixels. This array must be at least as large as width \* height. This value cannot be `null`. <br /> |
| `width` | `int`: The width of the bitmap <br /> |
| `height` | `int`: The height of the bitmap <br /> |
| `config` | `Bitmap.Config`: The bitmap config to create. If the config does not support per-pixel alpha (e.g. RGB_565), then the alpha bytes in the colors\[\] will be ignored (assumed to be FF) <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the width or height are \<= 0, or if the color array's length is less than the number of pixels. |

### createBitmap

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap createBitmap (Bitmap source, 
                int x, 
                int y, 
                int width, 
                int height, 
                Matrix m, 
                boolean filter)
```

Returns a bitmap from subset of the source bitmap,
transformed by the optional matrix. The new bitmap may be the
same object as source, or a copy may have been made. It is
initialized with the same density and color space as the original
bitmap.

If the source bitmap is immutable and the requested subset is the
same as the source bitmap itself, then the source bitmap is
returned and no new bitmap is created.

The returned bitmap will always be mutable except in the following scenarios:
(1) In situations where the source bitmap is returned and the source bitmap is immutable

(2) The source bitmap is a hardware bitmap. That is `https://developer.android.com/reference/android/graphics/Bitmap#getConfig()` is equivalent to
`https://developer.android.com/reference/android/graphics/Bitmap.Config#HARDWARE`

<br />

| Parameters ||
|---|---|
| `source` | `Bitmap`: The bitmap we are subsetting. This value cannot be `null`. <br /> |
| `x` | `int`: The x coordinate of the first pixel in source <br /> |
| `y` | `int`: The y coordinate of the first pixel in source <br /> |
| `width` | `int`: The number of pixels in each row <br /> |
| `height` | `int`: The number of rows <br /> |
| `m` | `Matrix`: Optional matrix to be applied to the pixels. This value may be `null`. <br /> |
| `filter` | `boolean`: true if the source should be filtered. Only applies if the matrix contains more than just translation. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | A bitmap that represents the specified subset of source. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the x, y, width, height values are outside of the dimensions of the source bitmap, or width is \<= 0, or height is \<= 0, or if the source bitmap has already been recycled |

### createBitmap

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap createBitmap (DisplayMetrics display, 
                int width, 
                int height, 
                Bitmap.Config config, 
                boolean hasAlpha, 
                ColorSpace colorSpace)
```

Returns a mutable bitmap with the specified width and height. Its
initial density is determined from the given `https://developer.android.com/reference/android/util/DisplayMetrics`.
The newly created bitmap is in the `https://developer.android.com/reference/android/graphics/ColorSpace.Named#SRGB`
color space.

<br />

| Parameters ||
|---|---|
| `display` | `DisplayMetrics`: Display metrics for the display this bitmap will be drawn on. This value may be `null`. <br /> |
| `width` | `int`: The width of the bitmap <br /> |
| `height` | `int`: The height of the bitmap <br /> |
| `config` | `Bitmap.Config`: The bitmap config to create. This value cannot be `null`. <br /> |
| `hasAlpha` | `boolean`: If the bitmap is ARGB_8888, RGBA_16F, or RGBA_1010102 this flag can be used to mark the bitmap as opaque. Doing so will clear the bitmap in black instead of transparent. <br /> |
| `colorSpace` | `ColorSpace`: The color space of the bitmap. If the config is `https://developer.android.com/reference/android/graphics/Bitmap.Config#RGBA_F16` and `https://developer.android.com/reference/android/graphics/ColorSpace.Named#SRGB` or `https://developer.android.com/reference/android/graphics/ColorSpace.Named#LINEAR_SRGB` is provided then the corresponding extended range variant is assumed. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the width or height are \<= 0, if Config is Config.HARDWARE (because hardware bitmaps are always immutable), if the specified color space is not `https://developer.android.com/reference/android/graphics/ColorSpace.Model#RGB`, if the specified color space's transfer function is not an `https://developer.android.com/reference/android/graphics/ColorSpace.Rgb.TransferParameters`, or if the color space is null |

### createBitmap

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap createBitmap (Bitmap src)
```

Returns a bitmap from the source bitmap. The new bitmap may
be the same object as source, or a copy may have been made. It is
initialized with the same density and color space as the original bitmap.

<br />

| Parameters ||
|---|---|
| `src` | `Bitmap`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value cannot be `null`. <br /> |

### createBitmap

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap createBitmap (Picture source)
```

Creates a Bitmap from the given `https://developer.android.com/reference/android/graphics/Picture` source of recorded drawing commands.

Equivalent to calling `https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(android.graphics.Picture,%20int,%20int,%20android.graphics.Bitmap.Config)` with
width and height the same as the Picture's width and height and a Config.HARDWARE
config.

<br />

| Parameters ||
|---|---|
| `source` | `Picture`: The recorded `https://developer.android.com/reference/android/graphics/Picture` of drawing commands that will be drawn into the returned Bitmap. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | An immutable bitmap with a HARDWARE config whose contents are created from the recorded drawing commands in the Picture source. This value cannot be `null`. <br /> |

### createBitmap

Added in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap createBitmap (DisplayMetrics display, 
                int[] colors, 
                int offset, 
                int stride, 
                int width, 
                int height, 
                Bitmap.Config config)
```

Returns a immutable bitmap with the specified width and height, with each
pixel value set to the corresponding value in the colors array. Its
initial density is determined from the given `https://developer.android.com/reference/android/util/DisplayMetrics`.
The newly created bitmap is in the `https://developer.android.com/reference/android/graphics/ColorSpace.Named#SRGB`
color space.

<br />

| Parameters ||
|---|---|
| `display` | `DisplayMetrics`: Display metrics for the display this bitmap will be drawn on. This value cannot be `null`. <br /> |
| `colors` | `int`: Array of sRGB `https://developer.android.com/reference/android/graphics/Color` used to initialize the pixels. This value cannot be `null`. <br /> |
| `offset` | `int`: Number of values to skip before the first color in the array of colors. <br /> |
| `stride` | `int`: Number of colors in the array between rows (must be \>= width or \<= -width). <br /> |
| `width` | `int`: The width of the bitmap <br /> |
| `height` | `int`: The height of the bitmap <br /> |
| `config` | `Bitmap.Config`: The bitmap config to create. If the config does not support per-pixel alpha (e.g. RGB_565), then the alpha bytes in the colors\[\] will be ignored (assumed to be FF). This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the width or height are \<= 0, or if the color array's length is less than the number of pixels. |

### createBitmap

Added in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap createBitmap (DisplayMetrics display, 
                int[] colors, 
                int width, 
                int height, 
                Bitmap.Config config)
```

Returns a immutable bitmap with the specified width and height, with each
pixel value set to the corresponding value in the colors array. Its
initial density is determined from the given `https://developer.android.com/reference/android/util/DisplayMetrics`.
The newly created bitmap is in the `https://developer.android.com/reference/android/graphics/ColorSpace.Named#SRGB`
color space.

<br />

| Parameters ||
|---|---|
| `display` | `DisplayMetrics`: Display metrics for the display this bitmap will be drawn on. This value may be `null`. <br /> |
| `colors` | `int`: Array of sRGB `https://developer.android.com/reference/android/graphics/Color` used to initialize the pixels. This array must be at least as large as width \* height. This value cannot be `null`. <br /> |
| `width` | `int`: The width of the bitmap <br /> |
| `height` | `int`: The height of the bitmap <br /> |
| `config` | `Bitmap.Config`: The bitmap config to create. If the config does not support per-pixel alpha (e.g. RGB_565), then the alpha bytes in the colors\[\] will be ignored (assumed to be FF). This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the width or height are \<= 0, or if the color array's length is less than the number of pixels. |

### createBitmap

Added in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap createBitmap (DisplayMetrics display, 
                int width, 
                int height, 
                Bitmap.Config config)
```

Returns a mutable bitmap with the specified width and height. Its
initial density is determined from the given `https://developer.android.com/reference/android/util/DisplayMetrics`.
The newly created bitmap is in the `https://developer.android.com/reference/android/graphics/ColorSpace.Named#SRGB`
color space.

<br />

| Parameters ||
|---|---|
| `display` | `DisplayMetrics`: Display metrics for the display this bitmap will be drawn on. This value may be `null`. <br /> |
| `width` | `int`: The width of the bitmap <br /> |
| `height` | `int`: The height of the bitmap <br /> |
| `config` | `Bitmap.Config`: The bitmap config to create. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the width or height are \<= 0, or if Config is Config.HARDWARE, because hardware bitmaps are always immutable |

### createBitmap

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap createBitmap (int[] colors, 
                int offset, 
                int stride, 
                int width, 
                int height, 
                Bitmap.Config config)
```

Returns a immutable bitmap with the specified width and height, with each
pixel value set to the corresponding value in the colors array. Its
initial density is as per `https://developer.android.com/reference/android/graphics/Bitmap#getDensity()`. The newly created
bitmap is in the `https://developer.android.com/reference/android/graphics/ColorSpace.Named#SRGB` color space.

<br />

| Parameters ||
|---|---|
| `colors` | `int`: Array of sRGB `https://developer.android.com/reference/android/graphics/Color` used to initialize the pixels. This value cannot be `null`. <br /> |
| `offset` | `int`: Number of values to skip before the first color in the array of colors. <br /> |
| `stride` | `int`: Number of colors in the array between rows (must be \>= width or \<= -width). <br /> |
| `width` | `int`: The width of the bitmap <br /> |
| `height` | `int`: The height of the bitmap <br /> |
| `config` | `Bitmap.Config`: The bitmap config to create. If the config does not support per-pixel alpha (e.g. RGB_565), then the alpha bytes in the colors\[\] will be ignored (assumed to be FF). This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the width or height are \<= 0, or if the color array's length is less than the number of pixels. |

### createBitmap

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap createBitmap (Picture source, 
                int width, 
                int height, 
                Bitmap.Config config)
```

Creates a Bitmap from the given `https://developer.android.com/reference/android/graphics/Picture` source of recorded drawing commands.

The bitmap will be immutable with the given width and height. If the width and height
are not the same as the Picture's width \& height, the Picture will be scaled to
fit the given width and height.

<br />

| Parameters ||
|---|---|
| `source` | `Picture`: The recorded `https://developer.android.com/reference/android/graphics/Picture` of drawing commands that will be drawn into the returned Bitmap. This value cannot be `null`. <br /> |
| `width` | `int`: The width of the bitmap to create. The picture's width will be scaled to match if necessary. <br /> |
| `height` | `int`: The height of the bitmap to create. The picture's height will be scaled to match if necessary. <br /> |
| `config` | `Bitmap.Config`: The `https://developer.android.com/reference/android/graphics/Bitmap.Config` of the created bitmap. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | An immutable bitmap with a configuration specified by the config parameter. This value cannot be `null`. <br /> |

### createBitmap

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap createBitmap (int width, 
                int height, 
                Bitmap.Config config, 
                boolean hasAlpha, 
                ColorSpace colorSpace)
```

Returns a mutable bitmap with the specified width and height. Its
initial density is as per `https://developer.android.com/reference/android/graphics/Bitmap#getDensity()`.

<br />

| Parameters ||
|---|---|
| `width` | `int`: The width of the bitmap <br /> |
| `height` | `int`: The height of the bitmap <br /> |
| `config` | `Bitmap.Config`: The bitmap config to create. This value cannot be `null`. <br /> |
| `hasAlpha` | `boolean`: If the bitmap is ARGB_8888, RGBA_16F, or RGBA_1010102 this flag can be used to mark the bitmap as opaque. Doing so will clear the bitmap in black instead of transparent. <br /> |
| `colorSpace` | `ColorSpace`: The color space of the bitmap. If the config is `https://developer.android.com/reference/android/graphics/Bitmap.Config#RGBA_F16` and `https://developer.android.com/reference/android/graphics/ColorSpace.Named#SRGB` or `https://developer.android.com/reference/android/graphics/ColorSpace.Named#LINEAR_SRGB` is provided then the corresponding extended range variant is assumed. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the width or height are \<= 0, if Config is Config.HARDWARE (because hardware bitmaps are always immutable), if the specified color space is not `https://developer.android.com/reference/android/graphics/ColorSpace.Model#RGB`, if the specified color space's transfer function is not an `https://developer.android.com/reference/android/graphics/ColorSpace.Rgb.TransferParameters`, or if the color space is null |

### createBitmap

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap createBitmap (DisplayMetrics display, 
                int width, 
                int height, 
                Bitmap.Config config, 
                boolean hasAlpha)
```

Returns a mutable bitmap with the specified width and height. Its
initial density is determined from the given `https://developer.android.com/reference/android/util/DisplayMetrics`.
The newly created bitmap is in the `https://developer.android.com/reference/android/graphics/ColorSpace.Named#SRGB`
color space.

<br />

| Parameters ||
|---|---|
| `display` | `DisplayMetrics`: Display metrics for the display this bitmap will be drawn on. This value may be `null`. <br /> |
| `width` | `int`: The width of the bitmap <br /> |
| `height` | `int`: The height of the bitmap <br /> |
| `config` | `Bitmap.Config`: The bitmap config to create. This value cannot be `null`. <br /> |
| `hasAlpha` | `boolean`: If the bitmap is ARGB_8888, RGBA_16F, or RGBA_1010102 this flag can be used to mark the bitmap as opaque. Doing so will clear the bitmap in black instead of transparent. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the width or height are \<= 0, or if Config is Config.HARDWARE, because hardware bitmaps are always immutable |

### createBitmap

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap createBitmap (int width, 
                int height, 
                Bitmap.Config config)
```

Returns a mutable bitmap with the specified width and height. Its
initial density is as per `https://developer.android.com/reference/android/graphics/Bitmap#getDensity()`. The newly created
bitmap is in the `https://developer.android.com/reference/android/graphics/ColorSpace.Named#SRGB` color space.

<br />

| Parameters ||
|---|---|
| `width` | `int`: The width of the bitmap <br /> |
| `height` | `int`: The height of the bitmap <br /> |
| `config` | `Bitmap.Config`: The bitmap config to create. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the width or height are \<= 0, or if Config is Config.HARDWARE, because hardware bitmaps are always immutable |

### createBitmap

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap createBitmap (int width, 
                int height, 
                Bitmap.Config config, 
                boolean hasAlpha)
```

Returns a mutable bitmap with the specified width and height. Its
initial density is as per `https://developer.android.com/reference/android/graphics/Bitmap#getDensity()`. The newly created
bitmap is in the `https://developer.android.com/reference/android/graphics/ColorSpace.Named#SRGB` color space.

<br />

| Parameters ||
|---|---|
| `width` | `int`: The width of the bitmap <br /> |
| `height` | `int`: The height of the bitmap <br /> |
| `config` | `Bitmap.Config`: The bitmap config to create. This value cannot be `null`. <br /> |
| `hasAlpha` | `boolean`: If the bitmap is ARGB_8888, RGBA_16F, or RGBA_1010102 this flag can be used to mark the bitmap as opaque. Doing so will clear the bitmap in black instead of transparent. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the width or height are \<= 0, or if Config is Config.HARDWARE, because hardware bitmaps are always immutable |

### createScaledBitmap

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap createScaledBitmap (Bitmap src, 
                int dstWidth, 
                int dstHeight, 
                boolean filter)
```

Creates a new bitmap, scaled from an existing bitmap, when possible. If the
specified width and height are the same as the current width and height of
the source bitmap, the source bitmap is returned and no new bitmap is
created.

<br />

| Parameters ||
|---|---|
| `src` | `Bitmap`: The source bitmap. This value cannot be `null`. <br /> |
| `dstWidth` | `int`: The new bitmap's desired width. <br /> |
| `dstHeight` | `int`: The new bitmap's desired height. <br /> |
| `filter` | `boolean`: Whether or not bilinear filtering should be used when scaling the bitmap. If this is true then bilinear filtering will be used when scaling which has better image quality at the cost of worse performance. If this is false then nearest-neighbor scaling is used instead which will have worse image quality but is faster. Recommended default is to set filter to 'true' as the cost of bilinear filtering is typically minimal and the improved image quality is significant. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | The new scaled bitmap or the source bitmap if no scaling is required. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if width is \<= 0, or height is \<= 0 |

### describeContents

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int describeContents ()
```

No special parcel contents.

<br />

| Returns ||
|---|---|
| `int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or - `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` |

### eraseColor

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void eraseColor (int c)
```

Fills the bitmap's pixels with the specified `https://developer.android.com/reference/android/graphics/Color`.

<br />

| Parameters ||
|---|---|
| `c` | `int` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if the bitmap is not mutable. |

### eraseColor

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void eraseColor (long color)
```

Fills the bitmap's pixels with the specified `ColorLong`.

<br />

| Parameters ||
|---|---|
| `color` | `long`: The color to fill as packed by the `https://developer.android.com/reference/android/graphics/Color` class. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the color space encoded in the `ColorLong` is invalid or unknown. |
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if the bitmap is not mutable. |

### extractAlpha

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Bitmap extractAlpha ()
```

Returns a new bitmap that captures the alpha values of the original.
This may be drawn with Canvas.drawBitmap(), where the color(s) will be
taken from the paint that is passed to the draw call.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | new bitmap containing the alpha channel of the original bitmap. This value cannot be `null`. <br /> |

### extractAlpha

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Bitmap extractAlpha (Paint paint, 
                int[] offsetXY)
```

Returns a new bitmap that captures the alpha values of the original.
These values may be affected by the optional Paint parameter, which
can contain its own alpha, and may also contain a MaskFilter which
could change the actual dimensions of the resulting bitmap (e.g.
a blur maskfilter might enlarge the resulting bitmap). If offsetXY
is not null, it returns the amount to offset the returned bitmap so
that it will logically align with the original. For example, if the
paint contains a blur of radius 2, then offsetXY\[\] would contains
-2, -2, so that drawing the alpha bitmap offset by (-2, -2) and then
drawing the original would result in the blur visually aligning with
the original.

The initial density of the returned bitmap is the same as the original's.

<br />

| Parameters ||
|---|---|
| `paint` | `Paint`: Optional paint used to modify the alpha values in the resulting bitmap. Pass null for default behavior. <br /> |
| `offsetXY` | `int`: Optional array that returns the X (index 0) and Y (index 1) offset needed to position the returned bitmap so that it visually lines up with the original. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | new bitmap containing the (optionally modified by paint) alpha channel of the original bitmap. This may be drawn with Canvas.drawBitmap(), where the color(s) will be taken from the paint that is passed to the draw call. <br /> |

### getAllocationByteCount

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getAllocationByteCount ()
```

Returns the size of the allocated memory used to store this bitmap's pixels.

This can be larger than the result of `https://developer.android.com/reference/android/graphics/Bitmap#getByteCount()` if a bitmap is reused to
decode other bitmaps of smaller size, or by manual reconfiguration. See `https://developer.android.com/reference/android/graphics/Bitmap#reconfigure(int,%20int,%20android.graphics.Bitmap.Config)`, `https://developer.android.com/reference/android/graphics/Bitmap#setWidth(int)`, `https://developer.android.com/reference/android/graphics/Bitmap#setHeight(int)`, `https://developer.android.com/reference/android/graphics/Bitmap#setConfig(android.graphics.Bitmap.Config)`, and `https://developer.android.com/reference/android/graphics/BitmapFactory.Options#inBitmap`. If a bitmap is not modified in this way, this value will be
the same as that returned by `https://developer.android.com/reference/android/graphics/Bitmap#getByteCount()`.

This value will not change over the lifetime of a Bitmap.

<br />

<br />

| Returns ||
|---|---|
| `int` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/graphics/Bitmap#reconfigure(int,%20int,%20android.graphics.Bitmap.Config)`

### getByteCount

Added in [API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getByteCount ()
```

Returns the minimum number of bytes that can be used to store this bitmap's pixels.

As of `https://developer.android.com/reference/android/os/Build.VERSION_CODES#KITKAT`, the result of this method can
no longer be used to determine memory usage of a bitmap. See `https://developer.android.com/reference/android/graphics/Bitmap#getAllocationByteCount()`.

<br />

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getColor

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Color getColor (int x, 
                int y)
```

Returns the `https://developer.android.com/reference/android/graphics/Color` at the specified location. Throws an exception
if x or y are out of bounds (negative or \>= to the width or height
respectively).

<br />

| Parameters ||
|---|---|
| `x` | `int`: The x coordinate (0...width-1) of the pixel to return <br /> |
| `y` | `int`: The y coordinate (0...height-1) of the pixel to return <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Color` | The `https://developer.android.com/reference/android/graphics/Color` at the specified coordinate. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if x, y exceed the bitmap's bounds |
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if the bitmap's config is `https://developer.android.com/reference/android/graphics/Bitmap.Config#HARDWARE` |

### getColorSpace

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ColorSpace getColorSpace ()
```

Returns the color space associated with this bitmap. If the color
space is unknown, this method returns null.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/ColorSpace` | <br /> |

### getConfig

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Bitmap.Config getConfig ()
```

If the bitmap's internal config is in one of the public formats, return
that config, otherwise return null.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap.Config` | <br /> |

### getDensity

Added in [API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getDensity ()
```

<br />

Returns the density for this bitmap.

The default density is the same density as the current display,
unless the current application does not support different screen
densities in which case it is
`https://developer.android.com/reference/android/util/DisplayMetrics#DENSITY_DEFAULT`. Note that
compatibility mode is determined by the application that was initially
loaded into a process -- applications that share the same process should
all have the same compatibility, or ensure they explicitly set the
density of their bitmaps appropriately.

<br />

<br />

| Returns ||
|---|---|
| `int` | A scaling factor of the default density or `https://developer.android.com/reference/android/graphics/Bitmap#DENSITY_NONE` if the scaling factor is unknown. <br /> |

**See also:**

- `https://developer.android.com/reference/android/graphics/Bitmap#setDensity(int)`
- `https://developer.android.com/reference/android/util/DisplayMetrics#DENSITY_DEFAULT`
- `https://developer.android.com/reference/android/util/DisplayMetrics#densityDpi`
- `https://developer.android.com/reference/android/graphics/Bitmap#DENSITY_NONE`

### getGainmap

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Gainmap getGainmap ()
```

Returns the gainmap or null if the bitmap doesn't contain a gainmap

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Gainmap` | <br /> |

### getGenerationId

Added in [API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getGenerationId ()
```

Returns the generation ID of this bitmap. The generation ID changes
whenever the bitmap is modified. This can be used as an efficient way to
check if a bitmap has changed.

<br />

| Returns ||
|---|---|
| `int` | The current generation ID for this bitmap. <br /> |

### getHardwareBuffer

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public HardwareBuffer getHardwareBuffer ()
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/hardware/HardwareBuffer` | `https://developer.android.com/reference/android/hardware/HardwareBuffer` which is internally used by hardware bitmap Note: the HardwareBuffer does \*not\* have an associated `https://developer.android.com/reference/android/graphics/ColorSpace`. To render this object the same as its rendered with this Bitmap, you should also call `https://developer.android.com/reference/android/graphics/Bitmap#getColorSpace()`. <br /> Must not be modified while a wrapped Bitmap is accessing it. Doing so will result in undefined behavior. <br /> . This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if the bitmap's config is not `https://developer.android.com/reference/android/graphics/Bitmap.Config#HARDWARE` or if the bitmap has been recycled. |

### getHeight

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getHeight ()
```

Returns the bitmap's height

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getNinePatchChunk

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public byte[] getNinePatchChunk ()
```

Returns an optional array of private data, used by the UI system for
some bitmaps. Not intended to be called by applications.

<br />

| Returns ||
|---|---|
| `byte[]` | This value may be `null`. <br /> |

### getPixel

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getPixel (int x, 
                int y)
```

Returns the `https://developer.android.com/reference/android/graphics/Color` at the specified location. Throws an exception
if x or y are out of bounds (negative or \>= to the width or height
respectively). The returned color is a non-premultiplied ARGB value in
the `https://developer.android.com/reference/android/graphics/ColorSpace.Named#SRGB` color space.

<br />

| Parameters ||
|---|---|
| `x` | `int`: The x coordinate (0...width-1) of the pixel to return <br /> |
| `y` | `int`: The y coordinate (0...height-1) of the pixel to return <br /> |

| Returns ||
|---|---|
| `int` | The argb `https://developer.android.com/reference/android/graphics/Color` at the specified coordinate <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if x, y exceed the bitmap's bounds |
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if the bitmap's config is `https://developer.android.com/reference/android/graphics/Bitmap.Config#HARDWARE` |

### getPixels

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void getPixels (int[] pixels, 
                int offset, 
                int stride, 
                int x, 
                int y, 
                int width, 
                int height)
```

Returns in pixels\[\] a copy of the data in the bitmap. Each value is
a packed int representing a `https://developer.android.com/reference/android/graphics/Color`. The stride parameter allows
the caller to allow for gaps in the returned pixels array between
rows. For normal packed results, just pass width for the stride value.
The returned colors are non-premultiplied ARGB values in the
`https://developer.android.com/reference/android/graphics/ColorSpace.Named#SRGB` color space.

<br />

| Parameters ||
|---|---|
| `pixels` | `int`: The array to receive the bitmap's colors. This value cannot be `null`. <br /> |
| `offset` | `int`: The first index to write into pixels\[\] <br /> |
| `stride` | `int`: The number of entries in pixels\[\] to skip between rows (must be \>= bitmap's width). Can be negative. <br /> |
| `x` | `int`: The x coordinate of the first pixel to read from the bitmap <br /> |
| `y` | `int`: The y coordinate of the first pixel to read from the bitmap <br /> |
| `width` | `int`: The number of pixels to read from each row <br /> |
| `height` | `int`: The number of rows to read <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/ArrayIndexOutOfBoundsException` | if the pixels array is too small to receive the specified number of pixels. |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if x, y, width, height exceed the bounds of the bitmap, or if abs(stride) \< width. |
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if the bitmap's config is `https://developer.android.com/reference/android/graphics/Bitmap.Config#HARDWARE` |

### getRowBytes

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getRowBytes ()
```

Return the number of bytes between rows in the bitmap's pixels. Note that
this refers to the pixels as stored natively by the bitmap. If you call
getPixels() or setPixels(), then the pixels are uniformly treated as
32bit values, packed according to the Color class.

As of `https://developer.android.com/reference/android/os/Build.VERSION_CODES#KITKAT`, this method
should not be used to calculate the memory usage of the bitmap. Instead,
see `https://developer.android.com/reference/android/graphics/Bitmap#getAllocationByteCount()`.

<br />

| Returns ||
|---|---|
| `int` | number of bytes between rows of the native bitmap pixels. <br /> |

### getScaledHeight

Added in [API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getScaledHeight (int targetDensity)
```

Convenience method that returns the height of this bitmap divided
by the density scale factor.

Returns the bitmap's height multiplied by the ratio of the target density to the bitmap's
source density

<br />

| Parameters ||
|---|---|
| `targetDensity` | `int`: The density of the target canvas of the bitmap. <br /> |

| Returns ||
|---|---|
| `int` | The scaled height of this bitmap, according to the density scale factor. <br /> |

### getScaledHeight

Added in [API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getScaledHeight (Canvas canvas)
```

Convenience for calling `https://developer.android.com/reference/android/graphics/Bitmap#getScaledHeight(int)` with the target
density of the given `https://developer.android.com/reference/android/graphics/Canvas`.

<br />

| Parameters ||
|---|---|
| `canvas` | `Canvas`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### getScaledHeight

Added in [API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getScaledHeight (DisplayMetrics metrics)
```

Convenience for calling `https://developer.android.com/reference/android/graphics/Bitmap#getScaledHeight(int)` with the target
density of the given `https://developer.android.com/reference/android/util/DisplayMetrics`.

<br />

| Parameters ||
|---|---|
| `metrics` | `DisplayMetrics`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### getScaledWidth

Added in [API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getScaledWidth (int targetDensity)
```

Convenience method that returns the width of this bitmap divided
by the density scale factor.

Returns the bitmap's width multiplied by the ratio of the target density to the bitmap's
source density

<br />

| Parameters ||
|---|---|
| `targetDensity` | `int`: The density of the target canvas of the bitmap. <br /> |

| Returns ||
|---|---|
| `int` | The scaled width of this bitmap, according to the density scale factor. <br /> |

### getScaledWidth

Added in [API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getScaledWidth (DisplayMetrics metrics)
```

Convenience for calling `https://developer.android.com/reference/android/graphics/Bitmap#getScaledWidth(int)` with the target
density of the given `https://developer.android.com/reference/android/util/DisplayMetrics`.

<br />

| Parameters ||
|---|---|
| `metrics` | `DisplayMetrics`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### getScaledWidth

Added in [API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getScaledWidth (Canvas canvas)
```

Convenience for calling `https://developer.android.com/reference/android/graphics/Bitmap#getScaledWidth(int)` with the target
density of the given `https://developer.android.com/reference/android/graphics/Canvas`.

<br />

| Parameters ||
|---|---|
| `canvas` | `Canvas`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### getWidth

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getWidth ()
```

Returns the bitmap's width

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### hasAlpha

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean hasAlpha ()
```

Returns true if the bitmap's config supports per-pixel alpha, and
if the pixels may contain non-opaque alpha values. For some configs,
this is always false (e.g. RGB_565), since they do not support per-pixel
alpha. However, for configs that do, the bitmap may be flagged to be
known that all of its pixels are opaque. In this case hasAlpha() will
also return false. If a config such as ARGB_8888 is not so flagged,
it will return true by default.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### hasGainmap

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean hasGainmap ()
```

Returns whether or not this Bitmap contains a Gainmap.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### hasMipMap

Added in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean hasMipMap ()
```

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.

<br />

| Returns ||
|---|---|
| `boolean` | true if the renderer should attempt to use mipmaps, false otherwise <br /> |

**See also:**

- `https://developer.android.com/reference/android/graphics/Bitmap#setHasMipMap(boolean)`

### isMutable

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isMutable ()
```

Returns true if the bitmap is marked as mutable (i.e. can be drawn into)

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isPremultiplied

Added in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isPremultiplied ()
```

<br />

Indicates whether pixels stored in this bitmaps are stored pre-multiplied.
When a pixel is pre-multiplied, the RGB components have been multiplied by
the alpha component. For instance, if the original color is a 50%
translucent red `(128, 255, 0, 0)`, the pre-multiplied form is
`(128, 128, 0, 0)`.

This method always returns false if `https://developer.android.com/reference/android/graphics/Bitmap#getConfig()` is
`https://developer.android.com/reference/android/graphics/Bitmap.Config#RGB_565`.

The return value is undefined if `https://developer.android.com/reference/android/graphics/Bitmap#getConfig()` is
`https://developer.android.com/reference/android/graphics/Bitmap.Config#ALPHA_8`.

This method only returns true if `https://developer.android.com/reference/android/graphics/Bitmap#hasAlpha()` returns true.
A bitmap with no alpha channel can be used both as a pre-multiplied and
as a non pre-multiplied bitmap.

Only pre-multiplied bitmaps may be drawn by the view system or
`https://developer.android.com/reference/android/graphics/Canvas`. If a non-pre-multiplied bitmap with an alpha channel is
drawn to a Canvas, a RuntimeException will be thrown.

<br />

<br />

| Returns ||
|---|---|
| `boolean` | true if the underlying pixels have been pre-multiplied, false otherwise <br /> |

**See also:**

- `https://developer.android.com/reference/android/graphics/Bitmap#setPremultiplied(boolean)`
- `https://developer.android.com/reference/android/graphics/BitmapFactory.Options#inPremultiplied`

### isRecycled

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isRecycled ()
```

Returns true if this bitmap has been recycled. If so, then it is an error
to try to access its pixels, and the bitmap will not draw.

<br />

| Returns ||
|---|---|
| `boolean` | true if the bitmap has been recycled <br /> |

### prepareToDraw

Added in [API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void prepareToDraw ()
```

Builds caches associated with the bitmap that are used for drawing it.

Starting in `https://developer.android.com/reference/android/os/Build.VERSION_CODES#N`, this call initiates an asynchronous
upload to the GPU on RenderThread, if the Bitmap is not already uploaded. With Hardware
Acceleration, Bitmaps must be uploaded to the GPU in order to be rendered. This is done by
default the first time a Bitmap is drawn, but the process can take several milliseconds,
depending on the size of the Bitmap. Each time a Bitmap is modified and drawn again, it must
be re-uploaded.

Calling this method in advance can save time in the first frame it's used. For example, it
is recommended to call this on an image decoding worker thread when a decoded Bitmap is about
to be displayed. It is recommended to make any pre-draw modifications to the Bitmap before
calling this method, so the cached, uploaded copy may be reused without re-uploading.
In `https://developer.android.com/reference/android/os/Build.VERSION_CODES#KITKAT` and below, for purgeable bitmaps, this call would attempt to ensure that the pixels have been decoded.

<br />

<br />

### reconfigure

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void reconfigure (int width, 
                int height, 
                Bitmap.Config config)
```

<br />

Modifies the bitmap to have a specified width, height, and `https://developer.android.com/reference/android/graphics/Bitmap.Config`, without affecting the underlying allocation backing the bitmap.
Bitmap pixel data is not re-initialized for the new configuration.

This method can be used to avoid allocating a new bitmap, instead
reusing an existing bitmap's allocation for a new configuration of equal
or lesser size. If the Bitmap's allocation isn't large enough to support
the new configuration, an IllegalArgumentException will be thrown and the
bitmap will not be modified.

The result of `https://developer.android.com/reference/android/graphics/Bitmap#getByteCount()` will reflect the new configuration,
while `https://developer.android.com/reference/android/graphics/Bitmap#getAllocationByteCount()` will reflect that of the initial
configuration.

Note: This may change this result of hasAlpha(). When converting to 565,
the new bitmap will always be considered opaque. When converting from 565,
the new bitmap will be considered non-opaque, and will respect the value
set by setPremultiplied().

WARNING: This method should NOT be called on a bitmap currently in use
by the view system, Canvas, or the AndroidBitmap NDK API. It does not
make guarantees about how the underlying pixel buffer is remapped to the
new config, just that the allocation is reused. Additionally, the view
system does not account for bitmap properties being modifying during use,
e.g. while attached to drawables.

In order to safely ensure that a Bitmap is no longer in use by the
View system it is necessary to wait for a draw pass to occur after
invalidate()'ing any view that had previously drawn the Bitmap in the last
draw pass due to hardware acceleration's caching of draw commands. As
an example, here is how this can be done for an ImageView:

```
      ImageView myImageView = ...;
      final Bitmap myBitmap = ...;
      myImageView.setImageDrawable(null);
      myImageView.post(new Runnable() {
          public void run() {
              // myBitmap is now no longer in use by the ImageView
              // and can be safely reconfigured.
              myBitmap.reconfigure(...);
          }
      });
 
```

<br />

<br />

<br />

| Parameters ||
|---|---|
| `width` | `int` <br /> |
| `height` | `int` <br /> |
| `config` | `Bitmap.Config`: This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/graphics/Bitmap#setWidth(int)`
- `https://developer.android.com/reference/android/graphics/Bitmap#setHeight(int)`
- `https://developer.android.com/reference/android/graphics/Bitmap#setConfig(android.graphics.Bitmap.Config)`

### recycle

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void recycle ()
```

Immediately releases the pixel data associated with this Bitmap.

Call this method to release a Bitmap that is certainly no longer needed, such as with a
Bitmap that was created as an intermediate buffer in a transformation. Calling this
method will release the pixel memory immediately, rather than wait for a future Garbage
Collection.

Avoid calling this method on Bitmaps that were used in a View or that may be referenced
elsewhere, as it may be unsafe.

After calling this method, any subsequent attempt to access the bitmap's pixel data
(e.g., using `getPixels()` or `setPixels()`) will throw an exception, and the
bitmap will draw nothing. This operation cannot be reversed.

<br />

### sameAs

Added in [API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean sameAs (Bitmap other)
```

Given another bitmap, return true if it has the same dimensions, config,
and pixel data as this bitmap. If any of those differ, return false.
If other is null, return false.


This method may take several seconds to complete, so it should
only be called from a worker thread.

<br />

| Parameters ||
|---|---|
| `other` | `Bitmap`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

### setColorSpace

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setColorSpace (ColorSpace colorSpace)
```

<br />

Modifies the bitmap to have the specified `https://developer.android.com/reference/android/graphics/ColorSpace`, without
affecting the underlying allocation backing the bitmap.

This affects how the framework will interpret the color at each pixel. A bitmap
with `https://developer.android.com/reference/android/graphics/Bitmap.Config#ALPHA_8` never has a color space, since a color space does not
affect the alpha channel. Other `Config`s must always have a non-null
`ColorSpace`.

<br />

<br />

| Parameters ||
|---|---|
| `colorSpace` | `ColorSpace`: to assign to the bitmap. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If the specified color space is `null`, not `https://developer.android.com/reference/android/graphics/ColorSpace.Model#RGB`, or whose components min/max values reduce the numerical range compared to the previously assigned color space. Prior to `https://developer.android.com/reference/android/os/Build.VERSION_CODES#UPSIDE_DOWN_CAKE`, `IllegalArgumentException` will also be thrown if the specified color space has a transfer function that is not an `https://developer.android.com/reference/android/graphics/ColorSpace.Rgb.TransferParameters`. Starting from `https://developer.android.com/reference/android/os/Build.VERSION_CODES#UPSIDE_DOWN_CAKE`, the color spaces with non ICC parametric curve transfer function are allowed. E.g., `https://developer.android.com/reference/android/graphics/ColorSpace.Named#BT2020_HLG`. |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If the `Config` (returned by `https://developer.android.com/reference/android/graphics/Bitmap#getConfig()`) is `https://developer.android.com/reference/android/graphics/Bitmap.Config#ALPHA_8`. |

### setConfig

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setConfig (Bitmap.Config config)
```

<br />

Convenience method for calling `https://developer.android.com/reference/android/graphics/Bitmap#reconfigure(int,%20int,%20android.graphics.Bitmap.Config)`
with the current height and width.

WARNING: this method should not be used on bitmaps currently used by
the view system, see `https://developer.android.com/reference/android/graphics/Bitmap#reconfigure(int,%20int,%20android.graphics.Bitmap.Config)` for more
details.

<br />

<br />

| Parameters ||
|---|---|
| `config` | `Bitmap.Config`: This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/graphics/Bitmap#reconfigure(int,%20int,%20android.graphics.Bitmap.Config)`
- `https://developer.android.com/reference/android/graphics/Bitmap#setWidth(int)`
- `https://developer.android.com/reference/android/graphics/Bitmap#setHeight(int)`

### setDensity

Added in [API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setDensity (int density)
```

<br />

Specifies the density for this bitmap. When the bitmap is
drawn to a Canvas that also has a density, it will be scaled
appropriately.

<br />

<br />

| Parameters ||
|---|---|
| `density` | `int`: The density scaling factor to use with this bitmap or `https://developer.android.com/reference/android/graphics/Bitmap#DENSITY_NONE` if the density is unknown. <br /> |

**See also:**

- `https://developer.android.com/reference/android/graphics/Bitmap#getDensity()`
- `https://developer.android.com/reference/android/util/DisplayMetrics#DENSITY_DEFAULT`
- `https://developer.android.com/reference/android/util/DisplayMetrics#densityDpi`
- `https://developer.android.com/reference/android/graphics/Bitmap#DENSITY_NONE`

### setGainmap

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setGainmap (Gainmap gainmap)
```

Sets a gainmap on this bitmap, or removes the gainmap if null

<br />

| Parameters ||
|---|---|
| `gainmap` | `Gainmap`: This value may be `null`. <br /> |

### setHasAlpha

Added in [API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setHasAlpha (boolean hasAlpha)
```

Tell the bitmap if all of the pixels are known to be opaque (false)
or if some of the pixels may contain non-opaque alpha values (true).
Note, for some configs (e.g. RGB_565) this call is ignored, since it
does not support per-pixel alpha values.

This is meant as a drawing hint, as in some cases a bitmap that is known
to be opaque can take a faster drawing case than one that may have
non-opaque per-pixel alpha values.

<br />

| Parameters ||
|---|---|
| `hasAlpha` | `boolean` <br /> |

### setHasMipMap

Added in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setHasMipMap (boolean hasMipMap)
```

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.

<br />

| Parameters ||
|---|---|
| `hasMipMap` | `boolean`: indicates whether the renderer should attempt to use mipmaps <br /> |

**See also:**

- `https://developer.android.com/reference/android/graphics/Bitmap#hasMipMap()`

### setHeight

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setHeight (int height)
```

<br />

Convenience method for calling `https://developer.android.com/reference/android/graphics/Bitmap#reconfigure(int,%20int,%20android.graphics.Bitmap.Config)`
with the current width and config.

WARNING: this method should not be used on bitmaps currently used by
the view system, see `https://developer.android.com/reference/android/graphics/Bitmap#reconfigure(int,%20int,%20android.graphics.Bitmap.Config)` for more
details.

<br />

<br />

| Parameters ||
|---|---|
| `height` | `int` <br /> |

**See also:**

- `https://developer.android.com/reference/android/graphics/Bitmap#reconfigure(int,%20int,%20android.graphics.Bitmap.Config)`
- `https://developer.android.com/reference/android/graphics/Bitmap#setWidth(int)`
- `https://developer.android.com/reference/android/graphics/Bitmap#setConfig(android.graphics.Bitmap.Config)`

### setPixel

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setPixel (int x, 
                int y, 
                int color)
```

<br />

Write the specified `https://developer.android.com/reference/android/graphics/Color` into the bitmap (assuming it is
mutable) at the x,y coordinate. The color must be a
non-premultiplied ARGB value in the `https://developer.android.com/reference/android/graphics/ColorSpace.Named#SRGB`
color space.

<br />

<br />

| Parameters ||
|---|---|
| `x` | `int`: The x coordinate of the pixel to replace (0...width-1) <br /> |
| `y` | `int`: The y coordinate of the pixel to replace (0...height-1) <br /> |
| `color` | `int`: The ARGB color to write into the bitmap <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if x, y are outside of the bitmap's bounds. |
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if the bitmap is not mutable |

### setPixels

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setPixels (int[] pixels, 
                int offset, 
                int stride, 
                int x, 
                int y, 
                int width, 
                int height)
```

<br />

Replace pixels in the bitmap with the colors in the array. Each element
in the array is a packed int representing a non-premultiplied ARGB
`https://developer.android.com/reference/android/graphics/Color` in the `https://developer.android.com/reference/android/graphics/ColorSpace.Named#SRGB` color space.

<br />

<br />

| Parameters ||
|---|---|
| `pixels` | `int`: The colors to write to the bitmap. This value cannot be `null`. <br /> |
| `offset` | `int`: The index of the first color to read from pixels\[\] <br /> |
| `stride` | `int`: The number of colors in pixels\[\] to skip between rows. Normally this value will be the same as the width of the bitmap, but it can be larger (or negative). <br /> |
| `x` | `int`: The x coordinate of the first pixel to write to in the bitmap. <br /> |
| `y` | `int`: The y coordinate of the first pixel to write to in the bitmap. <br /> |
| `width` | `int`: The number of colors to copy from pixels\[\] per row <br /> |
| `height` | `int`: The number of rows to write to the bitmap <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/ArrayIndexOutOfBoundsException` | if the pixels array is too small to receive the specified number of pixels. |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if x, y, width, height are outside of the bitmap's bounds. |
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if the bitmap is not mutable |

### setPremultiplied

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setPremultiplied (boolean premultiplied)
```

Sets whether the bitmap should treat its data as pre-multiplied.

Bitmaps are always treated as pre-multiplied by the view system and
`https://developer.android.com/reference/android/graphics/Canvas` for performance reasons. Storing un-pre-multiplied data in
a Bitmap (through `https://developer.android.com/reference/android/graphics/Bitmap#setPixel(int,%20int,%20int)`, `https://developer.android.com/reference/android/graphics/Bitmap#setPixels(int[],%20int,%20int,%20int,%20int,%20int,%20int)`, or `https://developer.android.com/reference/android/graphics/BitmapFactory.Options#inPremultiplied`)
can lead to incorrect blending if drawn by the framework.

This method will not affect the behavior of a bitmap without an alpha
channel, or if `https://developer.android.com/reference/android/graphics/Bitmap#hasAlpha()` returns false.

Calling `https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(android.graphics.Bitmap)` or `https://developer.android.com/reference/android/graphics/Bitmap#createScaledBitmap(android.graphics.Bitmap,%20int,%20int,%20boolean)` with a source
Bitmap whose colors are not pre-multiplied may result in a RuntimeException,
since those functions require drawing the source, which is not supported for
un-pre-multiplied Bitmaps.

<br />

<br />

| Parameters ||
|---|---|
| `premultiplied` | `boolean` <br /> |

**See also:**

- `https://developer.android.com/reference/android/graphics/Bitmap#isPremultiplied()`
- `https://developer.android.com/reference/android/graphics/BitmapFactory.Options#inPremultiplied`

### setWidth

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setWidth (int width)
```

<br />

Convenience method for calling `https://developer.android.com/reference/android/graphics/Bitmap#reconfigure(int,%20int,%20android.graphics.Bitmap.Config)`
with the current height and config.

WARNING: this method should not be used on bitmaps currently used by
the view system, see `https://developer.android.com/reference/android/graphics/Bitmap#reconfigure(int,%20int,%20android.graphics.Bitmap.Config)` for more
details.

<br />

<br />

| Parameters ||
|---|---|
| `width` | `int` <br /> |

**See also:**

- `https://developer.android.com/reference/android/graphics/Bitmap#reconfigure(int,%20int,%20android.graphics.Bitmap.Config)`
- `https://developer.android.com/reference/android/graphics/Bitmap#setHeight(int)`
- `https://developer.android.com/reference/android/graphics/Bitmap#setConfig(android.graphics.Bitmap.Config)`

### wrapHardwareBuffer

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Bitmap wrapHardwareBuffer (HardwareBuffer hardwareBuffer, 
                ColorSpace colorSpace)
```

Create a hardware bitmap backed by a `https://developer.android.com/reference/android/hardware/HardwareBuffer`.

The passed HardwareBuffer's usage flags must contain
`https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_SAMPLED_IMAGE`.

The bitmap will keep a reference to the buffer so that callers can safely close the
HardwareBuffer without affecting the Bitmap. However the HardwareBuffer must not be
modified while a wrapped Bitmap is accessing it. Doing so will result in undefined behavior.

<br />

| Parameters ||
|---|---|
| `hardwareBuffer` | `HardwareBuffer`: The HardwareBuffer to wrap. This value cannot be `null`. <br /> |
| `colorSpace` | `ColorSpace`: The color space of the bitmap. Must be a `https://developer.android.com/reference/android/graphics/ColorSpace.Rgb` colorspace. If null, SRGB is assumed. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap` | A bitmap wrapping the buffer, or null if there was a problem creating the bitmap. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the HardwareBuffer has an invalid usage, or an invalid colorspace is given. |

### writeToParcel

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void writeToParcel (Parcel p, 
                int flags)
```

Write the bitmap and its pixels to the parcel. The bitmap can be
rebuilt from the parcel by calling CREATOR.createFromParcel().

If this bitmap is `https://developer.android.com/reference/android/graphics/Bitmap.Config#HARDWARE`, it may be unparceled with a different pixel
format (e.g. 565, 8888), but the content will be preserved to the best quality permitted
by the final pixel format

<br />

| Parameters ||
|---|---|
| `p` | `Parcel`: Parcel object to write the bitmap data into. This value cannot be `null`. <br /> |
| `flags` | `int`: Additional flags about how the object should be written. May be 0 or `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` |