▲ 图1.2.3 转换成128×64点阵4、转换成字节
根据【1.1.1:OLED显示图片】中的OLED的数据编码方式,将边缘图片转换成1024个字节。
def oleddata(d):
outd = []
d[d!=0] = 1
h,w = shape(d)
line = h//8
c12 = [2**i for i in range(8)]
printf(sum(d))
for i in range(line):
startline = i*8
endline = startline+8
for j in range(w):
data = d[startline:endline, j]
printf(data)
num = sum([x*y for x,y in zip(data, c12)])
outd.append(num)
return outd
下面是其中衣服图片转换后的字节。
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 224, 56, 12, 6, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 3, 4, 9, 11, 18, 50, 18, 4, 84, 84, 148, 20, 20, 36, 32, 40, 40, 40, 40, 40, 72, 64, 80, 208, 16, 224, 16, 80, 80, 80, 80, 80, 64, 15, 136, 143, 129, 129, 129, 2, 65, 129, 129, 128, 128, 128, 0, 0, 0, 0, 15, 0, 15, 16, 31, 16, 31, 0, 4, 7, 0, 255, 0, 176, 31, 16, 16, 31, 16, 16, 7, 4, 248, 0, 0, 0, 248, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 124, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 6, 28, 112, 192, 0, 0, 0, 0, 0, 0, 0, 255, 0, 254, 0, 2, 1, 13, 35, 221, 0, 129, 126, 0, 20, 58, 3, 1, 1, 238, 50, 14, 112, 216, 73, 197, 89, 17, 225, 2, 2, 254, 1, 2, 2, 252, 4, 8, 8, 9, 9, 1, 248, 8, 8, 8, 224, 32, 32, 32, 33, 33, 33, 33, 33, 32, 96, 64, 64, 64, 64, 0, 0, 0, 0, 0, 0, 0, 248, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 124, 0, 0, 192, 96, 32, 223, 64, 255, 0, 128, 238, 138, 136, 255, 138, 139, 170, 168, 138, 250, 128, 128, 128, 179, 8, 8, 8, 11, 8, 8, 57, 192, 15, 0, 254, 1, 0, 0, 196, 187, 0, 0, 0, 0, 0, 0, 255, 0, 28, 226, 1, 251, 134, 48, 80, 136, 136, 64, 112, 24, 8, 8, 24, 160, 32, 0, 0, 0, 0, 0, 0, 192, 103, 56, 80, 80, 48, 32, 64, 192, 160, 160, 64, 64, 64, 128, 0, 0, 128, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 18, 18, 11, 73, 152, 113, 134, 56, 136, 56, 64, 80, 160, 50, 24, 14, 16, 56, 32, 68, 52, 36, 201, 121, 130, 113, 27, 17, 255, 128, 30, 0, 255, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 255, 0, 1, 246, 8, 161, 48, 28, 7, 1, 128, 128, 128, 128, 143, 137, 153, 180, 161, 128, 128, 128, 128, 128, 143, 240, 0, 0, 248, 136, 134, 132, 254, 64, 64, 1, 3, 6, 4, 4, 73, 99, 22, 36, 104, 72, 80, 144, 160, 64, 64, 128, 128, 0, 0, 0, 0, 3, 2, 2, 2, 2, 98, 178, 20, 36, 100, 132, 4, 12, 8, 216, 48, 0, 192, 120, 72, 68, 244, 146, 210, 2, 168, 41, 43, 2, 36, 38, 34, 34, 39, 44, 51, 32, 21, 38, 37, 36, 36, 208, 80, 156, 167, 160, 160, 160, 76, 48, 13, 9, 139, 46, 32, 32, 31, 32, 255, 0, 0, 0, 1, 254, 0, 0, 0, 0, 192, 120, 7, 128, 160, 119, 72, 73, 120, 74, 74, 105, 59, 72, 8, 248, 136, 122, 170, 8, 238, 194, 98, 58, 14, 0, 0, 0, 127, 192, 4, 8, 17, 16, 17, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 2, 2, 4, 5, 8, 16, 240, 16, 252, 68, 36, 32, 48, 21, 28, 10, 65, 243, 10, 98, 31, 64, 143, 243, 140, 118, 131, 137, 133, 134, 0, 128, 195, 162, 12, 20, 20, 20, 20, 20, 20, 20, 36, 36, 36, 36, 36, 36, 36, 39, 32, 35, 36, 40, 40, 47, 36, 68, 68, 70, 85, 85, 85, 85, 87, 81, 87, 80, 80, 64, 160, 191, 160, 160, 160, 160, 161, 175, 136, 144, 144, 159, 144, 16, 80, 80, 80, 80, 86, 81, 81, 82, 84, 80, 93, 81, 17, 0, 0, 0, 0, 0, 0, 0, 0, 3, 14, 24, 112, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 7, 4, 4, 4, 4, 64, 188, 6, 66, 59, 104, 78, 65, 0, 97, 142, 48, 14, 0, 32, 192, 112, 14, 225, 24, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 64, 64, 64, 64, 64, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 12, 8, 24, 48, 96, 192, 0, 0, 0, 0, 0, 1, 6, 28, 112, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 16, 16, 8, 15, 3, 2, 0, 0, 14, 176, 104, 15, 0, 0, 0, 0, 0, 255, 0, 128, 127, 0, 0, 0, 0, 0, 0, 0, 0