From 8666d684aa22a4c94db311644d60c5fb0e8e3f6e Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Mon, 20 Dec 2021 05:12:35 +0000 Subject: [PATCH] de-duplicate code Signed-off-by: Ivailo Monev --- src/gui/image/qpixmapdata.cpp | 46 +---------------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/src/gui/image/qpixmapdata.cpp b/src/gui/image/qpixmapdata.cpp index 71ee84ea2..f365d3837 100644 --- a/src/gui/image/qpixmapdata.cpp +++ b/src/gui/image/qpixmapdata.cpp @@ -119,46 +119,7 @@ bool QPixmapData::scroll(int dx, int dy, const QRect &rect) void QPixmapData::setMask(const QBitmap &mask) { - if (mask.size().isEmpty()) { - if (depth() != 1) - fromImage(toImage().convertToFormat(QImage::Format_RGB32), - Qt::AutoColor); - } else { - QImage image = toImage(); - const int w = image.width(); - const int h = image.height(); - - switch (image.depth()) { - case 1: { - const QImage imageMask = mask.toImage().convertToFormat(image.format()); - const int bpl = image.bytesPerLine(); - uchar *dest = image.bits(); - for (int y = 0; y < h; ++y) { - const uchar *mscan = imageMask.constScanLine(y); - uchar *tscan = QFAST_SCAN_LINE(dest, bpl, y); - for (int i = 0; i < bpl; ++i) - tscan[i] &= mscan[i]; - } - break; - } - default: { - const QImage imageMask = mask.toImage().convertToFormat(QImage::Format_MonoLSB); - image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); - const int bpl = image.bytesPerLine(); - uchar *dest = image.bits(); - for (int y = 0; y < h; ++y) { - const uchar *mscan = imageMask.constScanLine(y); - QRgb *tscan = reinterpret_cast(QFAST_SCAN_LINE(dest, bpl, y)); - for (int x = 0; x < w; ++x) { - if (!(mscan[x>>3] & qt_pixmap_bit_mask[x&7])) - tscan[x] = 0; - } - } - break; - } - } - fromImage(image, Qt::AutoColor); - } + fromImage(qt_mask_image(toImage(), mask.toImage()), Qt::AutoColor); } QBitmap QPixmapData::mask() const @@ -226,9 +187,4 @@ QImage* QPixmapData::buffer() return 0; } - QT_END_NAMESPACE - - - -