I am trying to render a WSQ image in a QLabel in PyQt5. The WSQ image is in an xml file which is located in a zip file. Here is my approach:
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)
The second but last line causes the program to freeze/hang but if I do:
with file('/tmp/finger_print.wsq', 'wb') as f:
f.write(finger_data)
I am able to view the image in a WSQ viewer. I understand Qt has plugins for different image formats, Is there an image plugin I am missing?
Thanks in advance for your help.
-Abraham.
The image formats Qt supports by default are:
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
So you'll either have to write a custom Qt image plugin, or somehow convert the image data to one of the formats Qt understands.