mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 10:52:56 +00:00
de-duplicate code
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
5f5394e948
commit
8666d684aa
1 changed files with 1 additions and 45 deletions
|
@ -119,46 +119,7 @@ bool QPixmapData::scroll(int dx, int dy, const QRect &rect)
|
||||||
|
|
||||||
void QPixmapData::setMask(const QBitmap &mask)
|
void QPixmapData::setMask(const QBitmap &mask)
|
||||||
{
|
{
|
||||||
if (mask.size().isEmpty()) {
|
fromImage(qt_mask_image(toImage(), mask.toImage()), Qt::AutoColor);
|
||||||
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<QRgb*>(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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QBitmap QPixmapData::mask() const
|
QBitmap QPixmapData::mask() const
|
||||||
|
@ -226,9 +187,4 @@ QImage* QPixmapData::buffer()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue