How can I create an `ImageAsset` from a `Bitmap` o...
# compose
r
How can I create an
ImageAsset
from a
Bitmap
object?
i
r
Thank you
@Ian Lake is there also a way of converting a
VectorAsset
created with
vectorResource(..)
into an
ImageAsset
?
i
Generally those aren't interchangeable things so the previous guidance has been that any API that takes an
ImageAsset
should have another overload that takes a
VectorAsset
(that's how
Icon
works for instance). I know there's been some recent work in this space - maybe @Nader Jawad has more info?
r
@Ian Lake I've been trying to draw a vector asset onto the canvas using
drawImage
but it's only accepting an
ImageAsset
and not a
VectorAsset
n
You can draw a VectorAsset by creating a VectorPainter from it and calling draw into a target canvas
Icon and Image already have convience methods to consume VectorAsset instances directly and create a VectorPainter on your behalf
You can create a VectorPainter by calling
rememberVectorPainter(myVectorAsset)
within a composable method
r
Thank you @Nader Jawad
c
@Manuel Vivo and I went through recently in this talk (about 18:00) https://chris.banes.dev/talks/2020/compose-for-existing-apps-dcemea/