color ramp calculation fixed for gradients with many stops

This commit is contained in:
Uwe Rathmann 2023-02-04 11:53:23 +01:00
parent 776468953d
commit 9d4c423591
2 changed files with 4 additions and 2 deletions

View File

@ -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 );

View File

@ -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 );