More PyQt6 nonsense

SIP can apparently no longer auto-convert QVector<Rgb>
This commit is contained in:
Kovid Goyal 2021-11-20 17:59:47 +05:30
parent 9957480ddb
commit 053fd6f5bf
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 3 deletions

View File

@ -73,10 +73,12 @@ QImage oil_paint(const QImage &image, const float radius=-1, const bool high_qua
sipRes = new QImage(oil_paint(*a0, a1, a2));
IMAGEOPS_SUFFIX
%End
QImage quantize(const QImage &image, unsigned int maximum_colors, bool dither, const QVector<QRgb> &palette);
QImage quantize(const QImage &image, unsigned int maximum_colors, bool dither, SIP_PYTUPLE);
%MethodCode
QVector<QRgb> palette(PyTuple_GET_SIZE(a3));
for (int i = 0; i < PyTuple_GET_SIZE(a3); i++) palette[i] = PyLong_AsUnsignedLong(PyTuple_GET_ITEM(a3, i));
IMAGEOPS_PREFIX
sipRes = new QImage(quantize(*a0, a1, a2, *a3));
sipRes = new QImage(quantize(*a0, a1, a2, palette));
IMAGEOPS_SUFFIX
%End

View File

@ -503,7 +503,7 @@ def quantize_image(img, max_colors=256, dither=True, palette=''):
img = blend_image(img)
if palette and isinstance(palette, string_or_bytes):
palette = palette.split()
return imageops.quantize(img, max_colors, dither, [QColor(x).rgb() for x in palette])
return imageops.quantize(img, int(max_colors), dither, tuple(QColor(x).rgb() for x in palette))
def eink_dither_image(img):