QXpmHandler: clean up write_xpm_image: scope variables better

... and fix spacing around operators and after flow-control keywords.

Change-Id: Iefaa03074536d13a655c91fb42aef6aa96c2665b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
bb10
Marc Mutz 2021-08-04 16:40:24 +02:00
parent ec40e50506
commit 2658f95d3c
1 changed files with 4 additions and 5 deletions

View File

@ -1128,12 +1128,11 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const
const int w = image.width();
const int h = image.height();
int ncolors = 0;
int x, y;
// build color table
for(y=0; y<h; y++) {
for (int y = 0; y < h; ++y) {
const QRgb *yp = reinterpret_cast<const QRgb *>(image.constScanLine(y));
for(x=0; x<w; x++) {
for (int x = 0; x < w; ++x) {
QRgb color = *(yp + x);
const auto [it, inserted] = colorMap.try_emplace(color, ncolors);
if (inserted)
@ -1168,10 +1167,10 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const
// write pixels, limit to 4 characters per pixel
QByteArray line;
for(y=0; y<h; y++) {
for (int y = 0; y < h; ++y) {
line.clear();
const QRgb *yp = reinterpret_cast<const QRgb *>(image.constScanLine(y));
for(x=0; x<w; x++) {
for (int x = 0; x < w; ++x) {
int color = (int)(*(yp + x));
line.append(xpm_color_name(cpp, colorMap[color]));
}