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>
This commit is contained in:
parent
74515a7a30
commit
6ba6e7585d
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user