summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2021-08-04 16:42:07 +0200
committerMarc Mutz <marc.mutz@kdab.com>2021-08-05 11:32:02 +0200
commit726119c43156d9522b7f22a8bcc3521980e7d7a8 (patch)
tree02eb3f556cd680e6752fdcd342c936ebe0931cb9 /src/gui/image
parent2658f95d3c3aafe3d3da20bf02d597f70277cd8f (diff)
QXpmHandler: clean up write_xpm_image: use conventional pointer arithmetic
... instead of *(array + index). Also fix a pointless cast from QRgb to int which the next line implicitly undoes (because colorMap has QRgb as key, not int) and get rid of the local variables that facilitated said fallacy in the first place. Change-Id: I71a92822ee2404646f6fb5533e40252f38e6b21f Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qxpmhandler.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp
index ae3fc8128d..501f3067fc 100644
--- a/src/gui/image/qxpmhandler.cpp
+++ b/src/gui/image/qxpmhandler.cpp
@@ -1133,8 +1133,7 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const
for (int y = 0; y < h; ++y) {
const QRgb *yp = reinterpret_cast<const QRgb *>(image.constScanLine(y));
for (int x = 0; x < w; ++x) {
- QRgb color = *(yp + x);
- const auto [it, inserted] = colorMap.try_emplace(color, ncolors);
+ const auto [it, inserted] = colorMap.try_emplace(yp[x], ncolors);
if (inserted)
++ncolors;
}
@@ -1170,10 +1169,8 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const
for (int y = 0; y < h; ++y) {
line.clear();
const QRgb *yp = reinterpret_cast<const QRgb *>(image.constScanLine(y));
- for (int x = 0; x < w; ++x) {
- int color = (int)(*(yp + x));
- line.append(xpm_color_name(cpp, colorMap[color]));
- }
+ for (int x = 0; x < w; ++x)
+ line.append(xpm_color_name(cpp, colorMap[yp[x]]));
s << ',' << Qt::endl << '\"' << line << '\"';
}
s << "};" << Qt::endl;