diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-07-08 12:32:29 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-07-08 16:26:36 +0200 |
commit | f44850b5c3464cdda0ee9b1ee858d95f3ffaa3e2 (patch) | |
tree | 580aa25716bfc88d57f15ad68f7bfa727aebc400 /src/gui/image | |
parent | f955bd8ced8b93d142b7f755665946424c6d3644 (diff) | |
parent | 3622ebaac51abd2e4d1541120ae3b6e42932359f (diff) |
Merge "Merge remote-tracking branch 'origin/dev' into wip/qt6"
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qpnghandler.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qxpmhandler.cpp | 30 |
2 files changed, 12 insertions, 20 deletions
diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 39d0807606..864a944fcb 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -417,7 +417,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scal } QSize outSize(width,height); if (!scaledSize.isEmpty() && quint32(scaledSize.width()) <= width && - quint32(scaledSize.height()) <= height && interlace_method == PNG_INTERLACE_NONE) { + quint32(scaledSize.height()) <= height && scaledSize != outSize && interlace_method == PNG_INTERLACE_NONE) { // Do inline downscaling outSize = scaledSize; if (doScaledRead) diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index deff56aa58..cf105b250a 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -1125,8 +1125,6 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const break; } - QString line; - // write header QTextStream s(device); s << "/* XPM */" << Qt::endl @@ -1137,35 +1135,29 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const QMap<QRgb, int>::Iterator c = colorMap.begin(); while (c != colorMap.end()) { QRgb color = c.key(); - if (image.format() != QImage::Format_RGB32 && !qAlpha(color)) - line = QString::asprintf("\"%s c None\"", - xpm_color_name(cpp, *c)); - else - line = QString::asprintf("\"%s c #%02x%02x%02x\"", - xpm_color_name(cpp, *c), - qRed(color), - qGreen(color), - qBlue(color)); + const QString line = image.format() != QImage::Format_RGB32 && !qAlpha(color) + ? QString::asprintf("\"%s c None\"", xpm_color_name(cpp, *c)) + : QString::asprintf("\"%s c #%02x%02x%02x\"", xpm_color_name(cpp, *c), + qRed(color), qGreen(color), qBlue(color)); ++c; s << ',' << Qt::endl << line; } // write pixels, limit to 4 characters per pixel - line.truncate(cpp*w); + QByteArray line; for(y=0; y<h; y++) { + line.clear(); const QRgb *yp = reinterpret_cast<const QRgb *>(image.constScanLine(y)); - int cc = 0; for(x=0; x<w; x++) { int color = (int)(*(yp + x)); const QByteArray chars(xpm_color_name(cpp, colorMap[color])); - line[cc++] = QLatin1Char(chars[0]); + line.append(chars[0]); if (cpp > 1) { - line[cc++] = QLatin1Char(chars[1]); + line.append(chars[1]); if (cpp > 2) { - line[cc++] = QLatin1Char(chars[2]); - if (cpp > 3) { - line[cc++] = QLatin1Char(chars[3]); - } + line.append(chars[2]); + if (cpp > 3) + line.append(chars[3]); } } } |