Python实现的基于ADB的Android远程工具(13)

if DEBUG:
                        print 'total rcv byte: %d' % rcvcnt
                    reply = s.recv(10)
                    s.close()
                    myfb.fb_data = bytearray(imagebuff)

if len(imagebuff) < myfb.fb_size:
                        continue

# convert raw-rgb to image
                    image = Image.frombuffer('RGBA',
                                            (myfb.fb_width, myfb.fb_height),
                                            myfb.fb_data,
                                            'raw',
                                            'RGBA',
                                            0,
                                            1)

lcd_w = image.size[0]
                    lcd_h = image.size[1]
                    if DEBUG:
                        print 'LCD size: %d x %d' % (lcd_w,lcd_h)
                    factor_w = 1.00
                    factor_h = 1.00
                    if lcd_w > max_lcd_w:
                        img_w = max_lcd_w
                        factor_w = float(img_w)/float(lcd_w)
                    if lcd_h > max_lcd_h:
                        img_h = max_lcd_h
                        factor_h = float(img_h)/float(lcd_h)
                    factor = min([factor_w, factor_h])
                    self.__img_factor = factor

# Keep the rate of w:h
                    img_w = int(lcd_w * factor)
                    img_h = int(lcd_h * factor)
                    if DEBUG:
                        print 'Image size: %d x %d' % (img_w, img_h)

# resize image
                    if (factor < 1.00):
                        image = image.resize((img_w, img_h))

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/4426fff1a55660c72a73dc3e3c0f172d.html