# HG changeset patch # User Chris Cannam # Date 1570616246 -3600 # Node ID 084c591622c5c7492db29baa81508ebd73e9308c # Parent 34311e13569585e789312e7e8e07934027ea6f96 Slightly streamline image scaling diff -r 34311e135695 -r 084c591622c5 layer/Colour3DPlotRenderer.cpp --- a/layer/Colour3DPlotRenderer.cpp Mon Oct 07 14:30:13 2019 +0100 +++ b/layer/Colour3DPlotRenderer.cpp Wed Oct 09 11:17:26 2019 +0100 @@ -779,7 +779,8 @@ } // Same format as the target cache - QImage target(targetWidth, targetHeight, QImage::Format_ARGB32_Premultiplied); + QImage target(targetWidth, targetHeight, + QImage::Format_ARGB32_Premultiplied); for (int y = 0; y < targetHeight; ++y) { @@ -788,12 +789,15 @@ int sy = int((uint64_t(y) * sourceHeight) / targetHeight); if (sy == sourceHeight) --sy; + // The source image is 8-bit indexed + const uchar *sourceLine = image.constScanLine(sy); + for (int x = 0; x < targetWidth; ++x) { int sx = int((uint64_t(x) * sourceWidth) / targetWidth); if (sx == sourceWidth) --sx; - - targetLine[x] = image.pixel(sx, sy); + + targetLine[x] = image.color(sourceLine[sx]); } }