系统: Ubantu 16 lts
思路: TK 显示 + adb 循环截图
注意:把脚本和 adb 执行文件放在同一目录下
效果:
其实是实时刷新的,只是截图是静态的。
完整记录: https://www.sspanda.com/python-38xing-dai-ma-shi-xian-androidshi-shi-hua-mian/
# -*- coding:utf-8 -*-
import io,os
from PIL import Image, ImageTk
import Tkinter as tk
import time
whbox ={"w_box":800,"h_box":800}
root = tk.Tk()
root.title("录频脚本")
root.geometry('450x800')
def resize(w, h, w_box, h_box, pil_image):
f1 = 1.0*w_box/w
f2 = 1.0*h_box/h
factor = min([f1, f2])
width = int(w*factor)
height = int(h*factor)
return pil_image.resize((width, height), Image.ANTIALIAS)
def Get_pic():
w_box = whbox['w_box']
h_box = whbox['h_box']
image_bytes = os.popen('./adb shell screencap -p').read()
data_stream = io.BytesIO(image_bytes)
pil_image = Image.open(data_stream)
w, h = pil_image.size
pil_image_resized = resize(w, h, w_box, h_box, pil_image)
wr, hr = pil_image_resized.size
tk_image = ImageTk.PhotoImage(pil_image_resized)
return tk_image
def flushpic():
bgm = Get_pic()
label.configure(image = bgm)
label.image = bgm
root.after(1, flushpic)
bgm = Get_pic()
label = tk.Label(root,image=bgm,width=whbox['w_box'], height=whbox['h_box']
)
label.pack()
root.after(0,flushpic)
root.mainloop()
1
dianbuixao 2017-04-20 21:54:31 +08:00
你真棒
|
2
xuyl 2017-04-20 22:44:26 +08:00
niubility
|
3
Kilerd 2017-04-20 23:49:38 +08:00
刷新率可以去到多少??? 60HZ ?
|
4
fcj558 2017-04-21 00:02:56 +08:00 via iPad
想起了 iOS 版网易云音乐的锁屏歌词实现方法就是一句歌词一直图片。
|
6
manhere 2017-04-21 00:17:24 +08:00
|
7
twoyuan 2017-04-21 18:12:20 +08:00
Vysor 就蛮好的
|