Skip to content

Commit

Permalink
compat.py: Add utility function to get raw bytes from QImages
Browse files Browse the repository at this point in the history
  • Loading branch information
zjp committed Apr 18, 2024
1 parent 3238de7 commit abb601c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions qtpy/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,14 @@ def isalive(obj):

return shiboken.isValid(obj)
return None


# =============================================================================
def getimagebytes(qimage):
if PYQT5:
return qimage.bits().asstring(qimage.byteCount())
if PYQT6:
return qimage.bits().asstring(qimage.sizeInBytes())
if PYSIDE2 or PYSIDE6:
return qimage.bits().tobytes()
raise QtBindingsNotFoundError()

0 comments on commit abb601c

Please sign in to comment.