MAT (Eclipse Memory Analyzer) - how to view bitmaps from memory dump

大憨熊 提交于 2019-11-27 05:59:44
HitOdessit

I have found a way to view such bitmaps:

  • First, you need to download and install GIMP
  • Next, find your Bitmap object in MAT, right-click on mBuffer field, in the popup menu choose "Copy" -> "Save Value To File" menu item and save value of this array to some file
  • give extension .data to that file
  • launch GIMP, choose "File" -> "Open", select your .data file and click Open button
  • "Load Image from Raw Data" dialog will appear. Here you need to set correct parameters for your bitmap
  • first, choose "Image type" as "RGB Alpha" (most Android resources have this image type, but you may need to experiment with other image types)
  • second, set correct Width and Height for your bitmap (correct dimensions can be found in the memory dump)

At that point you should already observe preview of original image. If you didn't, you can try to change some other parameters in "Load Image from Raw Data" dialog.

NOTE: to get a width and height of image you can look at mWidth and mHeight fields in MAT in attributes section as shown in image in question.

You can convert memory dumps from MAT to png using with ImageMagick on command line.

In MAT for related Bitmap object right click mBuffer field and select "Copy" -> "Save Value To File", name the file with an .rgba extension.

You need to note bitmap width and height from mWidth and mHeight fields, which you can see in Bitmap object.

Having ImageMagick command line tools installed (for Ubuntu apt-get install imagemagick), you issue convert command with the following parameters.

convert -size 'width'x'height' -depth 8 filename.rgba filename.png

For example

 convert -size 680x1209 -depth 8 phone_decor.rgba phone_decor.png

You can check generated png file via eog, like eog phone_decor.rgba on Ubuntu easily.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!