diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index 65ce05b2b..fd0fdd59d 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -173,11 +173,12 @@ void QRasterPixmapData::setMask(const QBitmap &mask) 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.scanLine(y); - uchar *tscan = image.scanLine(y); - int bytesPerLine = image.bytesPerLine(); - for (int i = 0; i < bytesPerLine; ++i) + 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; @@ -185,9 +186,11 @@ void QRasterPixmapData::setMask(const QBitmap &mask) 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.scanLine(y); - QRgb *tscan = (QRgb *)image.scanLine(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; diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp index 80a03ca9c..0d4ce875a 100644 --- a/src/gui/image/qpixmap_x11.cpp +++ b/src/gui/image/qpixmap_x11.cpp @@ -1346,16 +1346,18 @@ QImage QX11PixmapData::takeQImageFromXImage(XImage *xi) const if ((QSysInfo::ByteOrder == QSysInfo::LittleEndian && xi->byte_order == MSBFirst) || (QSysInfo::ByteOrder == QSysInfo::BigEndian && xi->byte_order == LSBFirst)) { + const int bpl = image.bytesPerLine(); + uchar* dest = image.bits(); for (int i=0; i < image.height(); i++) { if (depth() == 16) { - ushort *p = (ushort*)image.scanLine(i); + ushort *p = reinterpret_cast(QFAST_SCAN_LINE(dest, bpl, i)); const ushort *end = p + image.width(); while (p < end) { *p = ((*p << 8) & 0xff00) | ((*p >> 8) & 0x00ff); p++; } } else { - uint *p = (uint*)image.scanLine(i); + uint *p = reinterpret_cast(QFAST_SCAN_LINE(dest, bpl, i)); const uint *end = p + image.width(); while (p < end) { *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000) @@ -1563,9 +1565,12 @@ QImage QX11PixmapData::toImage(const XImage *xi, const QRect &rect) const } } else if (xi->bits_per_pixel == d) { // compatible depth char *xidata = xi->data; // copy each scanline - int bpl = qMin(image.bytesPerLine(),xi->bytes_per_line); + const int qbpl = image.bytesPerLine(); + const int bpl = qMin(qbpl, xi->bytes_per_line); + uchar* qdata = image.bits(); for (int y=0; yheight; y++) { - memcpy(image.scanLine(y), xidata, bpl); + uchar* tscan = QFAST_SCAN_LINE(qdata, qbpl, y); + memcpy(tscan, xidata, bpl); xidata += xi->bytes_per_line; } } else { diff --git a/src/gui/image/qpixmapdata.cpp b/src/gui/image/qpixmapdata.cpp index 46e04eaf6..f8a8e9608 100644 --- a/src/gui/image/qpixmapdata.cpp +++ b/src/gui/image/qpixmapdata.cpp @@ -25,6 +25,7 @@ #include "qimagereader.h" #include "qpixmap_raster_p.h" #include "qapplication_p.h" +#include "qdrawhelper_p.h" #include "qguicommon_p.h" QT_BEGIN_NAMESPACE @@ -132,11 +133,12 @@ void QPixmapData::setMask(const QBitmap &mask) 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.scanLine(y); - uchar *tscan = image.scanLine(y); - int bytesPerLine = image.bytesPerLine(); - for (int i = 0; i < bytesPerLine; ++i) + 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; @@ -144,9 +146,11 @@ void QPixmapData::setMask(const QBitmap &mask) 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.scanLine(y); - QRgb *tscan = (QRgb *)image.scanLine(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; @@ -178,14 +182,14 @@ QBitmap QPixmapData::mask() const mask.setColor(1, QColor(Qt::color1).rgba()); const int bpl = mask.bytesPerLine(); - + uchar *dest = mask.bits(); for (int y = 0; y < h; ++y) { - const QRgb *src = reinterpret_cast(image.scanLine(y)); - uchar *dest = mask.scanLine(y); - memset(dest, 0, bpl); + const QRgb *src = reinterpret_cast(image.constScanLine(y)); + uchar *tscan = QFAST_SCAN_LINE(dest, bpl, y); + ::memset(tscan, 0, bpl); for (int x = 0; x < w; ++x) { if (qAlpha(*src) > 0) - dest[x >> 3] |= qt_pixmap_bit_mask[x & 7]; + tscan[x >> 3] |= qt_pixmap_bit_mask[x & 7]; ++src; } }