summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2021-08-04 19:12:10 +0200
committerMarc Mutz <marc.mutz@kdab.com>2021-08-06 17:08:10 +0200
commit6ba6e7585dff4198aa3e4b23035ba95fb988400f (patch)
tree1c7aa6f415fb0e9b3e91dd59bbd0ad363dd209d1 /src/gui/image
parent74515a7a30b809a3ab0a2d67496e870ea3c872e6 (diff)
QXpmHandler: clean up write_xpm_image: cut out the QBA middle-man
Instead of appending to a QByteArray and then streaming that one, just stream the components of a line directly. QTextStream's op<<(const char*) is not subject to QT_NO_CAST_FROM_ASCII, etc., so can be used unconditionally. Change-Id: Idd97a75a1b5b939de7176d40880a2f328d01927d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qxpmhandler.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp
index 22bfab684c..da975869d5 100644
--- a/src/gui/image/qxpmhandler.cpp
+++ b/src/gui/image/qxpmhandler.cpp
@@ -1168,13 +1168,12 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const
}
// write pixels, limit to 4 characters per pixel
- QByteArray line;
for (int y = 0; y < h; ++y) {
- line.clear();
+ s << ',' << Qt::endl << '\"';
const QRgb *yp = reinterpret_cast<const QRgb *>(image.constScanLine(y));
for (int x = 0; x < w; ++x)
- line.append(xpm_color_name(cpp, colorMap[yp[x]]));
- s << ',' << Qt::endl << '\"' << line << '\"';
+ s << xpm_color_name(cpp, colorMap[yp[x]]);
+ s << '\"';
}
s << "};" << Qt::endl;
return (s.status() == QTextStream::Ok);