# BitmapPainter

Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/painter/BitmapPainter.kt+class:androidx.compose.ui.graphics.painter.BitmapPainter) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/All
- Cmn

  ```
  class BitmapPainter : Painter
  ```

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.compose.ui.graphics.painter.Painter](https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/Painter) ||
|   | ↳ | [androidx.compose.ui.graphics.painter.BitmapPainter](https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/BitmapPainter) |

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/Painter` implementation used to draw an `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ImageBitmap` into the provided canvas This implementation can handle applying alpha and `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ColorFilter` to it's drawn result

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/BitmapPainter#BitmapPainter(androidx.compose.ui.graphics.ImageBitmap,androidx.compose.ui.unit.IntOffset,androidx.compose.ui.unit.IntSize)(image: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ImageBitmap, srcOffset: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntOffset, srcSize: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize)` | Cmn |

| ### Public functions |
|---|---|---|
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/BitmapPainter#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/BitmapPainter#hashCode()()` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/BitmapPainter#toString()()` | Cmn |

| ### Protected functions |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/BitmapPainter#applyAlpha(kotlin.Float)(alpha: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Apply the provided alpha value returning true if it was applied successfully, or false if it could not be applied | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/BitmapPainter#applyColorFilter(androidx.compose.ui.graphics.ColorFilter)(colorFilter: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ColorFilter?)` Apply the provided color filter returning true if it was applied successfully, or false if it could not be applied | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawScope.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/BitmapPainter#(androidx.compose.ui.graphics.drawscope.DrawScope).onDraw()()` Implementation of drawing logic for instances of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/Painter`. | Cmn |

| ### Public properties |
|---|---|---|
| `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/BitmapPainter#intrinsicSize()` Return the dimension of the underlying `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ImageBitmap` as it's intrinsic width and height | Cmn |

### Inherited functions

From [androidx.compose.ui.graphics.painter.Painter](https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/Painter) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/Painter#applyLayoutDirection(androidx.compose.ui.unit.LayoutDirection)(layoutDirection: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/LayoutDirection)`

Apply the appropriate internal configuration to positioning content with the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/LayoutDirection`
Cmn `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawScope.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/Painter#(androidx.compose.ui.graphics.drawscope.DrawScope).draw(androidx.compose.ui.geometry.Size,kotlin.Float,androidx.compose.ui.graphics.ColorFilter)(size: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size, alpha: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, colorFilter: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ColorFilter?)` Cmn

## Public constructors

### BitmapPainter

Cmn Added in [1.9.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.9.0)

```
BitmapPainter(
    image: ImageBitmap,
    srcOffset: IntOffset = IntOffset.Zero,
    srcSize: IntSize = IntSize(image.width, image.height)
)
```

| Parameters |
|---|---|
| `image: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ImageBitmap` | The `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ImageBitmap` to draw |
| `srcOffset: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntOffset = IntOffset.Zero` | Optional offset relative to `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/BitmapPainter#image()` used to draw a subsection of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ImageBitmap`. By default this uses the origin of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/BitmapPainter#image()` |
| `srcSize: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize = IntSize(image.width, image.height)` | Optional dimensions representing size of the subsection of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/BitmapPainter#image()` to draw Both the offset and size must have the following requirements: 1. Left and top bounds must be greater than or equal to zero 2. Source size must be greater than zero 3. Source size must be less than or equal to the dimensions of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/BitmapPainter#image()` |

## Public functions

### equals

Cmn

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

Cmn

```
open fun hashCode(): Int
```

### toString

Cmn

```
open fun toString(): String
```

## Protected functions

### applyAlpha

Cmn

```
protected open fun applyAlpha(alpha: Float): Boolean
```

Apply the provided alpha value returning true if it was applied successfully, or false if it could not be applied

### applyColorFilter

Cmn

```
protected open fun applyColorFilter(colorFilter: ColorFilter?): Boolean
```

Apply the provided color filter returning true if it was applied successfully, or false if it could not be applied

### DrawScope.onDraw

Cmn Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/painter/BitmapPainter.kt+function:onDraw)

```
protected open fun DrawScope.onDraw(): Unit
```

Implementation of drawing logic for instances of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/Painter`. This is invoked internally within `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/Painter#(androidx.compose.ui.graphics.drawscope.DrawScope).draw(androidx.compose.ui.geometry.Size,kotlin.Float,androidx.compose.ui.graphics.ColorFilter)` after the positioning and configuring the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/Painter`

## Public properties

### intrinsicSize

Cmn

```
open val intrinsicSize: Size
```

Return the dimension of the underlying `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ImageBitmap` as it's intrinsic width and height