Google is committed to advancing racial equity for Black communities. See how.

ImagePainter

data class ImagePainter : Painter
kotlin.Any
   ↳ androidx.ui.graphics.painter.Painter
   ↳ androidx.ui.graphics.painter.ImagePainter

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

Summary

Public constructors
<init>(image: ImageAsset, srcOffset: IntOffset = IntOffset.Origin, srcSize: IntSize = IntSize(image.width, image.height))

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

Protected methods
Boolean
applyAlpha(alpha: Float)

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

Unit

Implementation of drawing logic for instances of Painter.

Inherited functions
Properties
Size

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

Public constructors

<init>

ImagePainter(
    image: ImageAsset,
    srcOffset: IntOffset = IntOffset.Origin,
    srcSize: IntSize = IntSize(image.width, image.height))

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

Parameters
image: ImageAsset The ImageAsset to draw
srcOffset: IntOffset = IntOffset.Origin Optional offset relative to image used to draw a subsection of the ImageAsset. By default this uses the origin of image
srcSize: IntSize = IntSize(image.width, image.height) Optional dimensions representing size of the subsection of image to draw Both the offset and size must have the following requirements:

Protected methods

applyAlpha

protected 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

protected 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

onDraw

protected fun DrawScope.onDraw(): Unit

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

Properties

intrinsicSize

val intrinsicSize: Size

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