Skip to content

Instantly share code, notes, and snippets.

@root-ansh
Created September 7, 2025 10:46
Show Gist options
  • Select an option

  • Save root-ansh/a33e69c3469f0536a7e36b9c27956792 to your computer and use it in GitHub Desktop.

Select an option

Save root-ansh/a33e69c3469f0536a7e36b9c27956792 to your computer and use it in GitHub Desktop.
private fun getCurrentImageViewBitmap(): Bitmap{
val drawable = binding.imagePreviewPlaceholder.drawable
val bitmap = if (drawable is BitmapDrawable) {
drawable.bitmap
} else {
val bitmap = createBitmap(drawable.intrinsicWidth, drawable.intrinsicHeight)
val canvas = Canvas(bitmap)
drawable.setBounds(0, 0, canvas.width, canvas.height)
drawable.draw(canvas)
bitmap
}
return bitmap
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment