gpt4 book ai didi

python - 在 QLabel 中渲染 WSQ 图像的最佳方式是什么

转载 作者:太空宇宙 更新时间:2023-11-04 06:07:36 24 4
gpt4 key购买 nike

我正在尝试在 PyQt5 的 QLabel 中渲染 WSQ 图像。 WSQ 图像位于 zip 文件中的 xml 文件中。这是我的方法:

import zipfile
import xml.etree.cElementTree as ET
import base64.b64decode as b64decode
from PyQt5 import QtGui, QtWidgets
...
try:
with zipfile.ZipFile(zfilename) as src_zip:
root = ET.fromstring(src_zip.open(xmlfilename).read())
except zipfile.BadZipFile as e:
root = None
finger_prints = []
if root:
for data in root.findall('.//Demographics/FingerData'):
finger_prints.append(b64decode(data.find('FingerprintImage').text))
...
finger_data = finger_prints.pop()
pixmap = QtGui.QPixmap()
pixmap.loadFromData(finger_data, 'WSQ') # freezes
QtWidgets.QLabel().setPixmap(pixmap)

第二行也是最后一行导致程序卡住/挂起,但如果我这样做:

with file('/tmp/finger_print.wsq', 'wb') as f:
f.write(finger_data)

我可以在 WSQ 查看器中查看图像。我知道 Qt 有针对不同图像格式的插件,是否有我缺少的图像插件?

预先感谢您的帮助。

-亚伯拉罕。

最佳答案

image formats Qt 默认支持的是:

 Format  Description                            Qt's support
BMP Windows Bitmap Read/write
GIF Graphic Interchange Format (optional) Read
JPG Joint Photographic Experts Group Read/write
JPEG Joint Photographic Experts Group Read/write
PNG Portable Network Graphics Read/write
PBM Portable Bitmap Read
PGM Portable Graymap Read
PPM Portable Pixmap Read/write
XBM X11 Bitmap Read/write
XPM X11 Pixmap Read/write

所以你要么必须写一个custom Qt image plugin ,或者以某种方式将图像数据转换为 Qt 可以理解的格式之一。

关于python - 在 QLabel 中渲染 WSQ 图像的最佳方式是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21119091/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com