{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

BitmapPainter

public final class BitmapPainter extends Painter

java.lang.Object
   ↳ androidx.compose.ui.graphics.painter.Painter
     ↳ androidx.compose.ui.graphics.painter.BitmapPainter

Painter implementation used to draw an ImageBitmap into the provided canvas This implementation can handle applying alpha and ColorFilter to it's drawn result

Summary

Public constructors

BitmapPainter(
    @NonNull ImageBitmap image,
    @NonNull IntOffset srcOffset,
    @NonNull IntSize srcSize
)

Public methods

boolean
equals(Object other)
@NonNull Size

Return the dimension of the underlying ImageBitmap as it's intrinsic width and height

int
@NonNull String

Protected methods

boolean
applyAlpha(float alpha)

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

boolean

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

void

Implementation of drawing logic for instances of Painter.

Inherited methods

From androidx.compose.ui.graphics.painter.Painter
boolean

Apply the appropriate internal configuration to positioning content with the given LayoutDirection

final void
orgKt.draw(
    @NonNull DrawScope receiver,
    @NonNull Size size,
    float alpha,
    ColorFilter colorFilter
)

Public constructors

BitmapPainter

public BitmapPainter(
    @NonNull ImageBitmap image,
    @NonNull IntOffset srcOffset,
    @NonNull IntSize srcSize
)
Parameters
@NonNull ImageBitmap image

The ImageBitmap to draw

@NonNull IntOffset srcOffset

Optional offset relative to image used to draw a subsection of the ImageBitmap. By default this uses the origin of image

@NonNull IntSize srcSize

Optional dimensions representing size of the subsection of 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 image

Public methods

equals

public boolean equals(Object other)

getIntrinsicSize

public @NonNull Size getIntrinsicSize()

Return the dimension of the underlying ImageBitmap as it's intrinsic width and height

hashCode

public int hashCode()

toString

public @NonNull String toString()

Protected methods

applyAlpha

protected boolean applyAlpha(float alpha)

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

applyColorFilter

protected boolean applyColorFilter(ColorFilter colorFilter)

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

onDraw

protected void onDraw(@NonNull DrawScope receiver)

Implementation of drawing logic for instances of Painter. This is invoked internally within draw after the positioning and configuring the Painter