From 053fd6f5bf208eabec14136a26d011d1c7bb0bec Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 20 Nov 2021 17:59:47 +0530 Subject: [PATCH] More PyQt6 nonsense SIP can apparently no longer auto-convert QVector --- src/calibre/utils/imageops/imageops.sip | 6 ++++-- src/calibre/utils/img.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/calibre/utils/imageops/imageops.sip b/src/calibre/utils/imageops/imageops.sip index d76c6b2a99..4bfc05a11a 100644 --- a/src/calibre/utils/imageops/imageops.sip +++ b/src/calibre/utils/imageops/imageops.sip @@ -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 &palette); +QImage quantize(const QImage &image, unsigned int maximum_colors, bool dither, SIP_PYTUPLE); %MethodCode + QVector 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 diff --git a/src/calibre/utils/img.py b/src/calibre/utils/img.py index 85049d99bb..e4b5d54123 100644 --- a/src/calibre/utils/img.py +++ b/src/calibre/utils/img.py @@ -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):