Last active
October 13, 2019 13:05
-
-
Save mj41/14767642e02dda7ce32ed26ce012fe12 to your computer and use it in GitHub Desktop.
Fast ADB screenshot helper script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -x | |
SCR_FPATH="$1" | |
[ -z "$1" ] && echo "Missing file basename." && exit 1 | |
[ ! -z "$2" ] && ADBDEV="$2" | |
[ -z "$ADBDEV"] && ADBDEV=`adb devices | grep -v 'List of' | perl -n0e '/(\S+)/; print $1'` | |
echo "Using ADB device '$ADBDEV'" | |
echo "Saving raw abd screenshot file to x.adbraw" | |
adb -s $ADBDEV exec-out screencap > x.adbraw | |
#adb -s $ADBDEV shell screencap > x.adbraw | |
#adb -s $ADBDEV shell screencap | perl -pe 's/\x0D\x0A/\x0A/g' > x.adbraw | |
echo "Info (ls, file, line 1 hexdump) about file" | |
ls -alh x.adbraw | |
file x.adbraw | |
hexdump -d x.adbraw | head -n 1 | |
echo "Removing header from file to create valid rgba file $SCR_FPATH.rgba" | |
dd if=x.adbraw of=$SCR_FPATH.rgba skip=1 bs=12 | |
echo "Info (file, line 1 hexdump) about $SCR_FPATH.rgba file" | |
file $SCR_FPATH.rgba | |
hexdump -d $SCR_FPATH.rgba | head -n 1 | |
echo "Trying to parse image size" | |
IMGRES=`hexdump -d x.adbraw | head -n 1 | perl -ne '/^\s*\d+\s+0*(\d+?)\s+\d+\s+0*(\d+?)\s+/; print "$1x$2"'` | |
echo "Image size found: $IMGRES" | |
echo "Using convert to create png image x.png" | |
convert -size $IMGRES -depth 8 $SCR_FPATH.rgba x.png | |
mv $SCR_FPATH.rgba $SCR_FPATH.data | |
echo "Showing x.png with eog programm" | |
eog x.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment