OTA. TGA提取
你还记得OTA格式吗?可以作为短信发送的简单图形格式?无论如何,我在我的手机上发现了一张很酷的OTA图片,我想把它提取成一种"正常"的图形格式,并将它添加到一个
T—恤衫
(它还将图像作为多个'#'写出到标准输出中)
选择 | 换行 | 行号
- #ota2tga
- def writetga(width,height,data,filename):
- f = open(filename,"wb")
- file = ""
- file+="%c%c%c" % (0,0,2)
- file+="%c%c%c%c%c" % (0,0,0,0,0)
- file+="%c%c%c%c" % (0,0,0,0)
- file+="%c%c" % ((width & 0x00ff)%0xff,(width & 0xff00)%0xff)
- file+="%c%c" % ((height & 0x00ff)%0xff,(height & 0xff00)%0xff)
- file+="%c%c" % (0x18,0x0)
- for i in range(height):
- for j in range(width):
- file+="%c%c%c" % (data[j+(height-1-i)*(width-1)][0],data[j+(height-1-i)*(width-1)][1],data[j+(height-1-i)*(width-1)][2])
- f.write(file)
- f.close()
- # add the name of your .ota file here.
- f = open("Grafikkmelding.ota","rb")
- info = ord(f.read(1))
- width = ord(f.read(1))
- height = ord(f.read(1))
- color = ord(f.read(1))
- pixmap = [[255,255,255]]*(72*28)
- print width
- print height
- x = 0
- y = 0
- l = ""
- for i in range(height):
- for j in range(width / 8):
- v = ord(f.read(1))
- for k in range(8):
- if( ((v >> 7-k) & 0x01) == 0):
- l+=" "
- pixmap[x+y*width] = [255,255,255]
- else:
- l+="#"
- pixmap[x+y*width] = [0,0,0]
- x+=1
- if(x > width):
- x=0
- y+=1
- l+="\n"
- f.close()
- print l
- writetga(width,height,pixmap,"output.tga")
-赞誉
评论已关闭