十六进制数据数组只包含灰色值,没有任何bmp文件信息。在
但是我知道分辨率(以像素为单位的宽度和高度),图像是灰色的,这意味着每个像素是8位的。在
有没有工具(联机或脱机)或代码从数据生成bmp文件?在
例如,下面的代码不起作用,结果是8*33
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy as np
s = "FFFFFFFF B0A7FFFF FFFFFFB3 807D8EFF FFFFFF94 707783CC FFFFFF89 7A8988A4 FFFFFFAD 929298BE FFFFFFAD 979AA8E2 FFFFFFAF 8991A9FF FFFFFF9F 808BA6FF FFFFFFAB 8694AFFF FFFFFFB2 8A96A0FF FFFFFFA8 859496FF FFFFFFB3 88809ADA FFFFFFA6 7B728DD7 FFFFFF85 6F7084D4 FFFFFF86 66647BDA FFFFFF8D 606482DD FFFFFF8B 666788DC FFFFFF7B 616282CE FFFFFF86 63657AC2 FFFFFFA1 72697FCB FFFFFF9B 75636FC6 FFFFFF88 6B596EC1 FFFFFF8B 675A80D5 FFFFFFA0 6D5E79DE FFFFFF8F 6B5C73FF FFFFD67F 605E8FFF FFFFDA7F 665B96FF FFFFD384 645A86FF FFFFFF84 6F6E86FF FFFFFFBE 979DC0FF FFFFFFFF C2CCFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFCBB9 9EB7FFFF FFBEA17C 677A99FF FFC59F66 565972C5 BACC9D70 595A76CA 9E997665 5E699EE0 977B6A6B 7F94B0FF FFBDA5A4 C4D9FFFF"
data = s.replace(" ", "").decode('hex')
plt.imsave('filename.bmp', np.array(data).reshape(8,33), cmap=cm.gray)
我正在寻找一个类似问题的答案,但无法在“纯”python中找到一个“快速”可理解的解决方案。 所以我写了一些代码来创建一个位图(从字符数组数据中转换为RGB值)。请阅读下面麻省理工学院许可证代码示例后的注释。它们描述了从任何数据创建位图所需的信息。在
我合并了来自http://blog.paphus.com/blog/2012/08/14/write-your-own-bitmaps/和{a2}的信息
我的输出是:
相关问题 更多 >
编程相关推荐