Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to save a bitmap from the debug console in Android Studio (Intellij)

In android studio you can view bitmaps from the debug console by clicking next to the variable (view bitmap). I was wondering if there was a way to save these to the computer your working on? Bitmap I'm trying to save

like image 609
Austi01101110 Avatar asked May 17 '16 19:05

Austi01101110


1 Answers

there is the possibility to evaluate code, when having the execution halted at a break-point, which permits pasting code into there, which may then perform the export by given Bitmap handle ... assuming the active application has already been granted permission to write to external storage.

this would be the code to paste and evaluate, where bitmap is the handle to export:

try {
    FileOutputStream output = new FileOutputStream(new File(Environment.getExternalStorageDirectory().toString(), "test.jpg"));
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, output);
    output.flush();
    output.close();
} catch (Exception e) {
    e.printStackTrace();
}

and this is how it should look alike:

evaluate code

the exported image can then be downloaded with the "Device File Explorer" from /mnt/sdcard.

like image 111
Martin Zeitler Avatar answered Oct 05 '22 15:10

Martin Zeitler