16

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

6
  • I am afraid the only solution is to save it locally then adb pull or something transfer client-server-ly to computer.
    – Geno Chen
    Commented Dec 17, 2018 at 17:09
  • try this gist.github.com/vxhviet/07429133e71b5fec2e39bd60171184cd
    – RA'sal
    Commented Dec 24, 2018 at 14:20
  • @GenoChen, I also think it is possible to store bitmap using adb command on terminal. If so can you tell me how I can do it?
    – Gary Chen
    Commented Apr 22, 2021 at 6:59
  • @XueQing What do you mean of "store bitmap using adb command"?
    – Geno Chen
    Commented Apr 22, 2021 at 7:06
  • 1
    @XueQing No, what I mean "locally" there means "inside the phone". That is, save it in the phone first, then adb pull to computer.
    – Geno Chen
    Commented Apr 22, 2021 at 7:14

1 Answer 1

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.