https://kotlinlang.org logo
Title
u

ursus

01/18/2023, 10:52 PM
What is the easiest way to add padding to
ImageBitmap
instance?
(I'm trying to create a tiled shader
Brush
, however my source vector is bounded very tightly so I need to add some "padding" to that)
val imageBitmap = drawable.toBitmap().asImageBitmap()
val shader = ImageShader(imageBitmap, TileMode.Repeated, TileMode.Repeated)
ShaderBrush(shader)
In View world I'd create a Canvas backed by Bitmap where I'd precalculate the size and drawBitmap in the center, and then pass the bitmap instance to the shader. In compose however I'm not sure how to go from Canvas to ImageBitmap
r

romainguy

01/18/2023, 10:58 PM
You can do the same
Create the larger bitmap and its Canvas, draw your source bitmap in it, then use asImageBitmap()
u

ursus

01/18/2023, 10:59 PM
Oh..facepalm 😀 thanks!