About

I'm Nicholas FitzRoy-Dale, a software developer from London, UK. I'm interested in embedded systems and operating system research, code optimisation, 8-bit music, rock climbing, shiny things...

Personal blog

Contact

Mon
Jul 27

Taking screenshots with an Android ADP1

There are lots of tutorials around the 'net to take screenshots using DDMS. Unfortunately using DDMS makes it difficult to take automated screenshots for testing purposes.

Fortunately Android uses reasonably-standard Unix conventions for access to devices, so you can read the data from /dev/graphics/fb0. The full procedure for getting a screenshot is:

adb pull /dev/graphics/fb0 fb0
python rgb565torgb888.py <fb0 >fb0.888
convert -depth 8 -size 320x480 RGB:fb0.888 fb0.png

Imagemagick (and thus convert) doesn't seem to deal with the 16-bit colour (565) image format, so I wrote a program to expand the data to 24-bit (888) before passing it to convert. You can use mine (rgb565torgb888.py, 311 bytes) or any other one you may find out there. :)

Update: If you're using Python 3, here is a version which will work for you. Use it without redirection, like this:

python3 rgb565torgb888_py3.py fb0 fb0.888