遥控器 ota_OTA。 到TGA提取器

遥控器 ota

您会记住OTA格式吗? 您可以作为SMS消息发送的简单图形格式吗? 无论如何,我在手机上找到了很酷的OTA图片,并想将其提取为“正常”图形格式,然后将其添加到

T恤衫 (它还会将图像以多个“#”写出到stdout中)

#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") 
-荣誉

翻译自: https://bytes.com/topic/python/insights/872877-ota-tga-extractor

遥控器 ota

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值