1. Download our Official Android App: Forums for Android!

Apps [SOLVED] Taking screenshots of blocking games

Discussion in 'Android Development' started by hansschmucker, Aug 1, 2011.

  1. hansschmucker

    hansschmucker Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    43
    Posts:
    257
    Joined:
    Apr 22, 2011

    Apr 22, 2011
    257
    43
    43
    Sometimes it's the simple things that can cause big issues, in this case I was unable to make screenshots of most 3D and a few 2D applications using normal applications. The normal ddms tool was able to do it, but did produce artifacts on fast-moving parts of the screen.

    The solution is actually pretty simple: Just pause the process before you take the screenshot, which you can do with a simple kill call.

    So I compiled everything into a simple batch file. Obviously you will have to adjust the path (I'm also using native win32 grep and sed, if you don't have them just move that part of the call to the Android command).

    It expects these arguments:
    1. part of the process name to stop, for example icarus
    2. output path minus .png

    For example:
    androidscreenshot.cmd icarus "C:\usr\home\images\icarus"

    Code (Text):
    1. @echo off
    2.  
    3. C:\usr\bin\x32\androidsdk\platform-tools\adb shell /system/xbin/ps|grep "app[^*]*%1"|sed "s/\\s*\([0-9]*\).*/\1/">"%TMP%\pid.android.screenshot"
    4. for /F %%i in (%TMP%\pid.android.screenshot) DO (
    5.     C:\usr\bin\x32\androidsdk\platform-tools\adb shell /system/xbin/kill -s STOP %%i
    6. )
    7.  
    8. ping -w 200 -n 1 192.168.2.255 > NUL
    9. C:\usr\bin\x32\androidsdk\platform-tools\adb shell cp /dev/graphics/fb0 /sdcard/tmp/screenshot.raw
    10.  
    11. for /F %%i in (%TMP%\pid.android.screenshot) DO (
    12.     C:\usr\bin\x32\androidsdk\platform-tools\adb shell /system/xbin/kill -s CONT %%i
    13. )
    14.  
    15. C:\usr\bin\x32\androidsdk\platform-tools\adb.exe pull /sdcard/tmp/screenshot.raw "%TMP%\android.screenshot.raw"
    16.  
    17. if NOT EXIST "%TMP%\android.screenshot.raw" (
    18.     echo Can't take screenshot.
    19.     pause
    20. )
    21.  
    22. C:\usr\bin\x32\ffmpeg\bin\ffmpeg.exe -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -s 320x480 -i "%TMP%\android.screenshot.raw" "%TMP%\android.screenshot%%d.png"
    23. set count=0
    24.  
    25. :LOOP
    26. if EXIST "%~2%count%.png" (
    27.     set /a count=%count%+1
    28.     goto :LOOP
    29. )
    30.  
    31. copy "%TMP%\android.screenshot1.png" "%~2%count%.png"
    32.  
    33.  
    34. del "%TMP%\android.screenshot.raw"
    35. del "%TMP%\android.screenshot*.png"
    36. del "%TMP%\pid.android.screenshot"
    37. C:\usr\bin\x32\androidsdk\platform-tools\adb shell rm /sdcard/tmp/screenshot.raw
     

    Advertisement

    alostpacket likes this.

Share This Page

Loading...