在数据库中,我有一个名为0xFFD8FFE000104A46494600010101012C012C0000FFDB00430008060607060508070707...
的列,其中包含以下字符开头的字符:
%1
如何根据此数据制作图像?
(可以从here查看和下载完整的数据。)
答案 0 :(得分:2)
您可以尝试沿着这些行('pict.txt'文件包含从您问题中的链接下载的十六进制数据):
findViewById()
运行它会显示以下图像:
打开图像存储文件并创建import io
from PIL import Image
with open('pict.txt', 'rb') as img_file:
img_file.read(2) # skip over the '0x'
hex_data = img_file.read()
binary_data = hex_data.decode('hex')
memory_file = io.BytesIO(binary_data)
img = Image.open(memory_file)
img.show()
PIL
类的实例后,您可以访问其他图像属性,例如Image
,img.format
,{{1根据需要等等(见Image Class Attributes)。