dtmilano / AndroidViewClient

Android ViewServer and ADB client
Apache License 2.0
1.63k stars 347 forks source link

ValueError: unrecognized mode in takeSnaphot() #62

Open Diob opened 11 years ago

Diob commented 11 years ago

if bpp = 32

the mode is set to AGR. This in an invalid and not recognized mode. There seems to be something wrong in the next line where the sorting is done. if sorted is removed, Then the mode becomes RGA

dtmilano commented 11 years ago

Can you enable debug by setting DEBUG = True in adbclient.py and copy the debug information here?

Diob commented 11 years ago

send(framebuffer:, checkok=True, reconnect=False) checkOk() checkConnected() checkConnected: returning True setAlarm(15) checkOk: recv= 'OKAY' setAlarm(0) checkOk: returning True receive() checkConnected() checkConnected: returning True receive: receiving 52 bytes receive: returning len= 52 takeSnapshot: (1, 32, 1536000, 800, 480, 16, 8, 0, 8, 8, 8, 0, 0) takeSnapshot: (1, 32, 1536000, 800, 480, 16, 8, 0, 8, 8, 8, 0, 0, 'AGR') send(, checkok=False, reconnect=False) takeSnapshot: reading 1536000 bytes receive() checkConnected() checkConnected: returning True receive: receiving 1536000 bytes __receive: returning len= 1536000 takeSnapshot: Image.frombuffer(AGR, (800, 480), data, raw, AGR, 0, 1) ERROR

......... screenshot = device.takeSnapshot().save(filename, 'PNG') File "AndroidViewClient-4.6.0/AndroidViewClient/src/com/dtmilano/android/adb/adbclient.py", line 371, in takeSnapshot return Image.frombuffer(mode, (width, height), received, 'raw', argMode, 0, 1) File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1858, in frombuffer return fromstring(mode, size, data, decoder_name, args) File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1796, in fromstring im = new(mode, size) File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1763, in new return Image()._new(core.fill(mode, size, color)) ValueError: unrecognized mode

It works if I force the mode and argmode to RGBA. However the colors do not seem right then.

dtmilano commented 11 years ago

Give AndroidViewClient 4.7.1 a try. It should detect your problem and generates a warning message instead of taking the incorrect alpha specification into account. You device tells its framebuffer is 32bpp but with 0 alpha bits. BTW, which device is it? There's something wrong with the framebuffer implementation.

On Wed, Oct 16, 2013 at 3:23 AM, Diob notifications@github.com wrote:

send(framebuffer:, checkok=True, reconnect=False) checkOk() checkConnected() checkConnected: returning True setAlarm(15) checkOk: recv= 'OKAY' setAlarm(0) checkOk: returning True receive() checkConnected() checkConnected: returning True receive: receiving 52 bytes receive: returning len= 52 takeSnapshot: (1, 32, 1536000, 800, 480, 16, 8, 0, 8, 8, 8, 0, 0) takeSnapshot: (1, 32, 1536000, 800, 480, 16, 8, 0, 8, 8, 8, 0, 0, 'AGR') send(, checkok=False, reconnect=False) takeSnapshot: reading 1536000 bytes receive() checkConnected() checkConnected: returning True receive: receiving 1536000 bytes __receive: returning len= 1536000 takeSnapshot: Image.frombuffer(AGR, (800, 480), data, raw, AGR, 0, 1) ERROR

......... screenshot = device.takeSnapshot().save(filename, 'PNG') File "AndroidViewClient-4.6.0/AndroidViewClient/src/com/dtmilano/android/adb/adbclient.py", line 371, in takeSnapshot return Image.frombuffer(mode, (width, height), received, 'raw', argMode, 0, 1) File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1858, in frombuffer return fromstring(mode, size, data, decoder_name, args) File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1796, in fromstring im = new(mode, size) File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1763, in new return Image()._new(core.fill(mode, size, color)) ValueError: unrecognized mode

— Reply to this email directly or view it on GitHubhttps://github.com/dtmilano/AndroidViewClient/issues/62#issuecomment-26397611 .

Have you read my blog ? http://dtmilano.blogspot.com android junit tests ui linux cult thin clients

dtmilano commented 11 years ago

Detected and prevented by 548df3c9a29e1714e1a850d50af028db31c2eedb

ghost commented 7 years ago

The issue persists in version 13.4.0. Here is what I am getting:

Traceback (most recent call last): File "android_view_client_example.py", line 94, in <module> takeScreenshot(device1, device1Serial) File "android_view_client_example.py", line 79, in takeScreenshot device.takeSnapshot(reconnect=True).save('/sdcard/uiengine/bugreport/' + deviceSerial + '_' + date + '.png', 'PNG') File "C:\AndroidViewClient-master\src\com\dtmilano\android\adb\adbclient.py", line 790, in takeSnapshot image = Image.frombuffer(mode, (width, height), received, 'raw', argMode, 0, 1) File "build\bdist.win32\egg\PIL\Image.py", line 2333, in frombuffer File "build\bdist.win32\egg\PIL\Image.py", line 2265, in frombytes File "build\bdist.win32\egg\PIL\Image.py", line 2229, in new ValueError: unrecognized mode

dtmilano commented 7 years ago

Can you attach the script you are using? Also, info about the device, android version, etc. so the problem can be reproduced.

ghost commented 7 years ago

Thank you for getting back to me. Here is the following code I used:

`def takeScreenshot(device, deviceSerial): timestamp = time.time() date = datetime.datetime.fromtimestamp(timestamp).strftime('%Y%m%d%H%M%S') device.shell('mkdir /sdcard/uiengine/screenshot') device.takeSnapshot(reconnect=True).save("/sdcard/uiengine/bugreport/" + deviceSerial + "_" + date + ".png", "PNG") print("Screenshot has been taken")

takeScreenshot(device1, device1Serial)`

The device I am using is the H871 (LG G6 AT&T) with Android version 7.0.

dtmilano commented 7 years ago

You can enable DEBUG in adbclient.py (line 53):

DEBUG = True

and check the debug messages produced. This will help us understand the problem better.

dtmilano commented 7 years ago

Also, in your script you can do

import com.dtmilano.android.adb.adbclient
com.dtmilano.android.adb.adbclient.DEBUG = True
device.takeSnapshot(reconnect=True).save("fimage.png")

and check the debug output