From 3fd7a7e51bf673b4c8e2e1cc2911be61a808543f Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Thu, 30 Jan 2025 09:09:31 +0100 Subject: [PATCH] improve image generation code --- src/dialogs/QskColorPicker.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/dialogs/QskColorPicker.cpp b/src/dialogs/QskColorPicker.cpp index 7b33ac0a..88d48825 100644 --- a/src/dialogs/QskColorPicker.cpp +++ b/src/dialogs/QskColorPicker.cpp @@ -29,15 +29,16 @@ namespace QColor color; float h, s; - for( int x = 0; x < image->width(); x++ ) + for ( int y = 0; y < image->height(); y++ ) { - h = static_cast< float >( x ) / image->width(); + s = 1.0 - static_cast< float >( y ) / image->height(); + auto line = reinterpret_cast< QRgb* >( image->scanLine( y ) ); - for( int y = 0; y < image->height(); y++ ) + for ( int x = 0; x < image->width(); x++ ) { - s = 1.0 - static_cast< float >( y ) / image->height(); + h = static_cast< float >( x ) / image->width(); color.setHsvF( h, s, v ); - image->setPixel( x, y, color.rgb() ); + *line++ = color.rgb(); } } }