Created
November 13, 2024 23:58
-
-
Save devapro/90c8adbe26e14f368baeb2299151e73d to your computer and use it in GitHub Desktop.
Android view get bitmap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Android view get bitmap | |
| private ImageBitmap getBitmapFromViewUsingCanvas(View view) { | |
| // Create a new Bitmap object with the desired width and height | |
| Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); | |
| // Create a new Canvas object using the Bitmap | |
| Canvas canvas = new Canvas(bitmap); | |
| // Draw the View into the Canvas | |
| view.draw(canvas); | |
| // Return the resulting Bitmap | |
| return asImageBitmap(bitmap); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment