changeset 1531:084c591622c5

Slightly streamline image scaling
author Chris Cannam
date Wed, 09 Oct 2019 11:17:26 +0100
parents 34311e135695
children 14a162f6870f
files layer/Colour3DPlotRenderer.cpp
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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]);
         }
     }