a=[]
for i in range(320):
for j in range(240):
#a.append("0x"+format(getPixHalfWord(px[i,j]),"4X"))
a.append(format(getPixHalfWord(px[j,i]),"X"))
import NaiveSerial
port=NaiveSerial.NaiveSerial(baudRate=115200)
for i in a:
i=int(i,base=16)
iL=int(i%256)
iH=int(i/256)
port.byte_write([iL,iH])[/mw_shl_code]
python的图形处理功能很强大,这一点不在话下。
im = Image.open('D:\Desktop\未标题-1.bmp')
px = im.load()
def getPixHalfWord(px1):
R=int(px1[0]/8)
G=int(px1[1]/4)
B=int(px1[2]/8)
return B+G*32+R*2048
a=[]
for i in range(320):
for j in range(240):
#a.append("0x"+format(getPixHalfWord(px[i,j]),"4X"))
a.append(format(getPixHalfWord(px[j,i]),"X"))
import NaiveSerial
port=NaiveSerial.NaiveSerial(baudRate=115200)
for i in a:
i=int(i,base=16)
iL=int(i%256)
iH=int(i/256)
port.byte_write([iL,iH])[/mw_shl_code]
我刚才的那段代码就很立竿见影了,直接运行即可导出565格式的字节码
一周热门 更多>