I am trying to get the edit text bitmap by using createBitmap()
but there is an error.
I have gone through different answers but they didn't work for me. Can anyone solve this issue?
Here is my code:
case : I am trying to place the edit text over the image just like a photo editor where we can edit and place the image
val bmp: Bitmap = Bitmap.createBitmap(binding.editImage.getDrawingCache())
editImage is the edit text where i can take the string from user
combineImages(test, bmp)
test
is the URI bitmap that I am getting when I clicked the image from the camera.
private fun combineImages(background: Bitmap?, foreground: Bitmap?): Bitmap {
val matrix = Matrix()
matrix.setValues(floatArrayOf(1f, .5f, 0f, 0f, 1f, 0f, 0f, 0f, 1f))
var width = 0
var height = 0
width = background!!.width
height = background.height
val cs: Bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
val comboImage = Canvas(cs)
val storage = Bitmap.createScaledBitmap(background, width, height, true)
comboImage.drawBitmap(storage,matrix, null)
if (foreground != null) {
comboImage.drawBitmap(foreground, matrix, null)
}
return cs
}
Please Help me!
Update
I have resolved this issue: Used the below answer
view.getDrawingCache() is deprecated in Android API 28