This is surrounded in a try, catch for the writing part, but if it isn’t in a try catch methods, the app seems to crash in the emulator.
I’m trying to save the canvas as a bitmap, then saving the bitmap to the storage…
screenshot = Bitmap.createBitmap(screenshot, 0, 0, 0, 0);
Canvas can = new Canvas(screenshot);
int i = 0;
String filename = "EnderShot";
while (new File(filename + i + ".png") != null){
FileOutputStream fos = null;
fos = openFileOutput(filename + i + ".png", Context.MODE_PRIVATE);
fos.write(screenshot.getByteCount());
fos.close();
}
This also saves it… So if anyone could work it out?
Anything you draw on the canvas, will infact be drawn on the underlying Bitmap.
in this case:
screenshotSo you already have the bitmap of the canvas, and don’t need to convert the canvas to bitmap.
TO save the bitmap to file do