AndroidViewClient icon indicating copy to clipboard operation
AndroidViewClient copied to clipboard

ValueError: unrecognized mode in takeSnaphot()

Open Diob opened this issue 12 years ago • 9 comments

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

Diob avatar Oct 15 '13 08:10 Diob

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

dtmilano avatar Oct 15 '13 15:10 dtmilano

__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.

Diob avatar Oct 16 '13 07:10 Diob

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 [email protected] 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 avatar Oct 21 '13 00:10 dtmilano

Detected and prevented by 548df3c9a29e1714e1a850d50af028db31c2eedb

dtmilano avatar Oct 21 '13 00:10 dtmilano

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

ghost avatar Aug 02 '17 17:08 ghost

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

dtmilano avatar Aug 02 '17 20:08 dtmilano

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.

ghost avatar Aug 02 '17 20:08 ghost

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 avatar Aug 02 '17 21:08 dtmilano

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

dtmilano avatar Aug 03 '17 14:08 dtmilano