From 9d4c423591bdda22084d00fb7d2c0aa9b944e4a0 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Sat, 4 Feb 2023 11:53:23 +0100 Subject: [PATCH] color ramp calculation fixed for gradients with many stops --- src/common/QskRgbValue.cpp | 3 ++- src/nodes/QskColorRamp.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/QskRgbValue.cpp b/src/common/QskRgbValue.cpp index 1431ddd1..9a091b7a 100644 --- a/src/common/QskRgbValue.cpp +++ b/src/common/QskRgbValue.cpp @@ -244,7 +244,8 @@ QImage QskRgb::colorTable( int size, const QskGradientStops& stops ) const auto n = index2 - index1; - for ( int j = 0; j < n; j++ ) + values[ index1 ] = ARGB2RGBA( rgb1 ); + for ( int j = 1; j < n; j++ ) { const auto rgb = QskRgb::interpolated( rgb1, rgb2, qreal( j ) / ( n - 1 ) ); values[ index1 + j] = ARGB2RGBA( rgb ); diff --git a/src/nodes/QskColorRamp.cpp b/src/nodes/QskColorRamp.cpp index c8021b06..9e6ba805 100644 --- a/src/nodes/QskColorRamp.cpp +++ b/src/nodes/QskColorRamp.cpp @@ -26,7 +26,8 @@ namespace from the internet ), */ - setImage( QskRgb::colorTable( 256, stops ) ); + const int size = qBound( 256, 2 * stops.count(), 1024 ); + setImage( QskRgb::colorTable( size, stops ) ); const auto wrapMode = this->wrapMode( spreadMode );