Pre-release
This release is a pre-release and may not be stable for production use.
qimage-hwc-bgrx-8888-ndarray-interop
Zero-copy conversion between Qt QImage (in Format_RGB32/Format_ARGB32) and NumPy ndarray (in HWC BGRX 8888 format).
Features
- Zero-copy: Memory is shared between objects - no pointless data copying!
- Cross-binding: Supports PyQt6, PyQt5, PyQt4, PySide6, PySide2, or PySide.
- Safety: Explicit checks for packing and format - no surprises.
Installation
Install your preferred Qt binding, then run:
pip install qimage-hwc-bgrx-8888-ndarray-interop
Usage
# coding=utf-8
from qimage_hwc_bgrx_8888_ndarray_interop import (
qimage_to_hwc_bgrx_8888_ndarray_view,
qimage_to_hwc_bgrx_8888_ndarray,
hwc_bgrx_8888_ndarray_to_qimage_view,
hwc_bgrx_8888_ndarray_to_qimage,
)
# Convert a QImage to numpy.ndarray (zero-copy view):
arr_view = qimage_to_hwc_bgrx_8888_ndarray_view(qimage)
# Convert a QImage to a copy of image data:
arr = qimage_to_hwc_bgrx_8888_ndarray(qimage)
# Convert a contiguous (H, W, 4) uint8 ndarray back to a QImage (zero-copy view):
qimg_view = hwc_bgrx_8888_ndarray_to_qimage_view(arr)
# Convert ndarray to a QImage (copies data):
qimg_copy = hwc_bgrx_8888_ndarray_to_qimage(arr)
Safety & Caveats
- Endianness: Only little-endian systems are supported (typical modern computers).
- On unsupported (big-endian) systems,
RuntimeErroris raised at import time.
- On unsupported (big-endian) systems,
- Tightly packed images only: QImage must have
bytesPerLine == width * 4for zero-copy view. - Memory lifetime matters:
- Do not let the QImage or ndarray be garbage collected while the other exists and references its buffer.
- If in doubt, use the
copy()variants.
Contributing
Contributions are welcome! Please submit pull requests or open issues on the GitHub repository.
License
This project is licensed under the MIT License.
Release files for qimage-hwc-bgrx-8888-ndarray-interop 0.1.0a0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| qimage_hwc_bgrx_8888_ndarray_interop-0.1.0a0.tar.gz | 4.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| qimage_hwc_bgrx_8888_ndarray_interop-0.1.0a0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 8.5 kB
Release files / qimage_hwc_bgrx_8888_ndarray_interop-0.1.0a0.tar.gz
| Download URL | qimage_hwc_bgrx_8888_ndarray_interop-0.1.0a0.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78b6f66993264a16e1cb779967ce7fa2d788899db17b94cf8838837b9a84afa4
|
|
BLAKE2b-256 checksum How to use checksums |
8f4ec77e27654bb55289a7909ee4d608240743d95a4dbe281e5d7b6be5f47ca6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.2
|
Release files / qimage_hwc_bgrx_8888_ndarray_interop-0.1.0a0-py2.py3-none-any.whl
| Download URL | qimage_hwc_bgrx_8888_ndarray_interop-0.1.0a0-py2.py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
2e865ffde38f82f99ee005d8a4d15c648ae31f31eabb9d8d609c6dd2a96980ba
|
|
BLAKE2b-256 checksum How to use checksums |
01a5122291b85f0e736b905de63e70fb0b8099330dd63d859b3fd30298da2ac5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.2
|