hmeine / qimage2ndarray

qimage2ndarray is a small python extension for quickly converting between QImages and numpy.ndarrays (in both directions).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

QImageFormat.from_code(pixel_format) is None

LiviuShiva opened this issue · comments

The method:
@staticmethod def from_code(code): for qimage_format in FORMATS.values(): if qimage_format.code == code: return qimage_format
Returns None
From the version 1.9.0 is missing: raise KeyError('No QImageFormat found for code %r' % code)

This because name in dir(QImage_Format) is always False:
for name, qimage_format in FORMATS.items(): if name in dir(QImage_Format): qimage_format.code = getattr(QImage_Format, name)

To avoid this behavior I changed the method from_code
@staticmethod def from_code(code): for _name, qimage_format in FORMATS.items(): if _name == code.name: return qimage_format
and works as before.

qimage2ndarray version 1.9.0
PySide6 version 6.4.1

Thank you!

The new code should ensure that only codes are returned that are supported by the current QImage, so I cannot just revert the code. But thanks for the report, I'll have to look into it!

Ah, I understand now – this issue has been fixed, but I have not officially released a new version yet!

I have just released version 1.10 which should work with PySide6 and PyQt6.