Se7eN
02/19/2021, 3:08 PMImageBitmap
? If yes, how do I draw text on the bitmap since there's no drawText
for Canvas(bitmap)
Denis
02/19/2021, 3:11 PMSe7eN
02/19/2021, 3:20 PMSe7eN
02/19/2021, 6:34 PMImageBitmap
for this kind of stuff but I have a problem. Let's say I draw a text to my bitmap but later I want to delete the text (or maybe move the text by dragging), how can I do that? Do I need to make a new bitmap and canvas and redraw my texts and images every time I delete them or change their position? I thought of something like this but I'm not sure if it's efficient:
var mainBitmap = mutableStateOf(ImageBitmap(size.width, size.height))
private var canvas = Canvas(mainBitmap.value)
fun addText(text: String) {
texts.add(text)
redrawCanvas()
}
fun onTextPositionChange(newPosition: Offset) {
...
redrawCanvas()
}
fun redrawCanvas() {
mainBitmap.value = ImageBitmap(size.width, size.height)
canvas = Canvas(mainBitmap.value)
texts.forEach {
canvas.nativeCanvas.drawText(...)
}
}