diff options
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qbmphandler.cpp | 16 | ||||
-rw-r--r-- | src/gui/image/qicon.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qiconloader.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qimage.cpp | 55 | ||||
-rw-r--r-- | src/gui/image/qimagepixmapcleanuphooks.cpp | 18 | ||||
-rw-r--r-- | src/gui/image/qpnghandler.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qxpmhandler.cpp | 2 |
7 files changed, 56 insertions, 41 deletions
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index b8290861af..9545abfd21 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -289,6 +289,12 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int format = QImage::Format_Mono; } + if (depth != 32) { + ncols = bi.biClrUsed ? bi.biClrUsed : 1 << nbits; + if (ncols < 1 || ncols > 256) // sanity check - don't run out of mem if color table is broken + return false; + } + if (bi.biHeight < 0) h = -h; // support images with negative height @@ -296,19 +302,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int image = QImage(w, h, format); if (image.isNull()) // could not create image return false; - } - - if (depth != 32) { - ncols = bi.biClrUsed ? bi.biClrUsed : 1 << nbits; - if (ncols < 1 || ncols > 256) // sanity check - don't run out of mem if color table is broken - return false; - image.setColorCount(ncols); + if (ncols) + image.setColorCount(ncols); // Ensure valid QImage } image.setDotsPerMeterX(bi.biXPelsPerMeter); image.setDotsPerMeterY(bi.biYPelsPerMeter); if (ncols > 0) { // read color table + image.setColorCount(ncols); uchar rgb[4]; int rgb_len = t == BMP_OLD ? 3 : 4; for (int i=0; i<ncols; i++) { diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 620cbde25d..0dec4b512d 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -284,7 +284,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St if (pm.isNull()) { int idx = pixmaps.count(); while (--idx >= 0) { - if (pe == &pixmaps[idx]) { + if (pe == &pixmaps.at(idx)) { pixmaps.remove(idx); break; } diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index cc8337fcb9..38782ac0a0 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -296,7 +296,7 @@ QIconTheme::QIconTheme(const QString &themeName) { QFile themeIndex; - QStringList iconDirs = QIcon::themeSearchPaths(); + const QStringList iconDirs = QIcon::themeSearchPaths(); for ( int i = 0 ; i < iconDirs.size() ; ++i) { QDir iconDir(iconDirs[i]); QString themeDir = iconDir.path() + QLatin1Char('/') + themeName; diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 3238d83729..3a31af8645 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -176,6 +176,9 @@ QImageData::~QImageData() data = 0; } +#if defined(_M_ARM) +#pragma optimize("", off) +#endif bool QImageData::checkForAlphaPixels() const { @@ -193,74 +196,81 @@ bool QImageData::checkForAlphaPixels() const break; case QImage::Format_ARGB32: case QImage::Format_ARGB32_Premultiplied: { - uchar *bits = data; + const uchar *bits = data; for (int y=0; y<height && !has_alpha_pixels; ++y) { + uint alphaAnd = 0xff000000; for (int x=0; x<width; ++x) - has_alpha_pixels |= (((uint *)bits)[x] & 0xff000000) != 0xff000000; + alphaAnd &= reinterpret_cast<const uint*>(bits)[x]; + has_alpha_pixels = (alphaAnd != 0xff000000); bits += bytes_per_line; } } break; case QImage::Format_RGBA8888: case QImage::Format_RGBA8888_Premultiplied: { - uchar *bits = data; + const uchar *bits = data; for (int y=0; y<height && !has_alpha_pixels; ++y) { + uchar alphaAnd = 0xff; for (int x=0; x<width; ++x) - has_alpha_pixels |= bits[x*4+3] != 0xff; + alphaAnd &= bits[x * 4+ 3]; + has_alpha_pixels = (alphaAnd != 0xff); bits += bytes_per_line; } } break; case QImage::Format_A2BGR30_Premultiplied: case QImage::Format_A2RGB30_Premultiplied: { - uchar *bits = data; + const uchar *bits = data; for (int y=0; y<height && !has_alpha_pixels; ++y) { + uint alphaAnd = 0xc0000000; for (int x=0; x<width; ++x) - has_alpha_pixels |= (((uint *)bits)[x] & 0xc0000000) != 0xc0000000; + alphaAnd &= reinterpret_cast<const uint*>(bits)[x]; + has_alpha_pixels = (alphaAnd != 0xc0000000); bits += bytes_per_line; } } break; case QImage::Format_ARGB8555_Premultiplied: case QImage::Format_ARGB8565_Premultiplied: { - uchar *bits = data; - uchar *end_bits = data + bytes_per_line; + const uchar *bits = data; + const uchar *end_bits = data + bytes_per_line; for (int y=0; y<height && !has_alpha_pixels; ++y) { + uchar alphaAnd = 0xff; while (bits < end_bits) { - has_alpha_pixels |= bits[0] != 0; + alphaAnd &= bits[0]; bits += 3; } + has_alpha_pixels = (alphaAnd != 0xff); bits = end_bits; end_bits += bytes_per_line; } } break; case QImage::Format_ARGB6666_Premultiplied: { - uchar *bits = data; - uchar *end_bits = data + bytes_per_line; + const uchar *bits = data; + const uchar *end_bits = data + bytes_per_line; for (int y=0; y<height && !has_alpha_pixels; ++y) { + uchar alphaAnd = 0xfc; while (bits < end_bits) { - has_alpha_pixels |= (bits[0] & 0xfc) != 0; + alphaAnd &= bits[0]; bits += 3; } + has_alpha_pixels = (alphaAnd != 0xfc); bits = end_bits; end_bits += bytes_per_line; } } break; case QImage::Format_ARGB4444_Premultiplied: { - uchar *bits = data; - uchar *end_bits = data + bytes_per_line; - + const uchar *bits = data; for (int y=0; y<height && !has_alpha_pixels; ++y) { - while (bits < end_bits) { - has_alpha_pixels |= (bits[0] & 0xf0) != 0; - bits += 2; - } - bits = end_bits; - end_bits += bytes_per_line; + ushort alphaAnd = 0xf000; + for (int x=0; x<width; ++x) + alphaAnd &= reinterpret_cast<const ushort*>(bits)[x]; + has_alpha_pixels = (alphaAnd != 0xf000); + bits += bytes_per_line; } } break; @@ -283,6 +293,9 @@ bool QImageData::checkForAlphaPixels() const return has_alpha_pixels; } +#if defined(_M_ARM) +#pragma optimize("", on) +#endif /*! \class QImage diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp index 10fa4303b2..f383e7a60e 100644 --- a/src/gui/image/qimagepixmapcleanuphooks.cpp +++ b/src/gui/image/qimagepixmapcleanuphooks.cpp @@ -84,38 +84,38 @@ void QImagePixmapCleanupHooks::removeImageHook(_qt_image_cleanup_hook_64 hook) void QImagePixmapCleanupHooks::executePlatformPixmapModificationHooks(QPlatformPixmap* pmd) { - QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks(); + const QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks(); // the global destructor for the pixmap and image hooks might have // been called already if the app is "leaking" global // pixmaps/images if (!h) return; - for (int i = 0; i < h->pixmapModificationHooks.count(); ++i) - h->pixmapModificationHooks[i](pmd); + for (auto hook : h->pixmapModificationHooks) + hook(pmd); } void QImagePixmapCleanupHooks::executePlatformPixmapDestructionHooks(QPlatformPixmap* pmd) { - QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks(); + const QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks(); // the global destructor for the pixmap and image hooks might have // been called already if the app is "leaking" global // pixmaps/images if (!h) return; - for (int i = 0; i < h->pixmapDestructionHooks.count(); ++i) - h->pixmapDestructionHooks[i](pmd); + for (auto hook : h->pixmapDestructionHooks) + hook(pmd); } void QImagePixmapCleanupHooks::executeImageHooks(qint64 key) { - QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks(); + const QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks(); // the global destructor for the pixmap and image hooks might have // been called already if the app is "leaking" global // pixmaps/images if (!h) return; - for (int i = 0; i < h->imageHooks.count(); ++i) - h->imageHooks[i](key); + for (auto hook : h->imageHooks) + hook(key); } diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 7fbb498bbb..96d6be502d 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -749,7 +749,7 @@ static void set_text(const QImage &image, png_structp png_ptr, png_infop info_pt QMap<QString, QString>::ConstIterator it = text.constBegin(); int i = 0; while (it != text.constEnd()) { - text_ptr[i].key = qstrdup(it.key().left(79).toLatin1().constData()); + text_ptr[i].key = qstrdup(it.key().leftRef(79).toLatin1().constData()); bool noCompress = (it.value().length() < 40); #ifdef PNG_iTXt_SUPPORTED diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index 5c8ff84929..756e31318f 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -1154,7 +1154,7 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const int cc = 0; for(x=0; x<w; x++) { int color = (int)(*(yp + x)); - QByteArray chars(xpm_color_name(cpp, colorMap[color])); + const QByteArray chars(xpm_color_name(cpp, colorMap[color])); line[cc++] = QLatin1Char(chars[0]); if (cpp > 1) { line[cc++] = QLatin1Char(chars[1]); |