Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-125634

For some RGB values, the final QRgb value obtained by converting RGB to HSL and then back to RGB is not equal to the value before conversion

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P3: Somewhat important
    • None
    • 5.14.2
    • GUI: Painting
    • None

    Description

      For some RGB values, the final QRgb value obtained by converting RGB to HSL and then back to RGB is not equal to the value before conversion

      bug rgb examples: 254, 2, 0   、  254, 4, 0   ......

       

      code demo:

      #include "mainwindow.h"
      #include <QApplication>
      #include <QColor>
      
      int main(int argc, char *argv[])
      { 
          QApplication a(argc, argv); 
          QRgb preCol = qRgb(254, 2, 0); //pre is 4294836736
      
          qreal h, s, l;
          QColor rgbColor(preCol);
          rgbColor.getHslF(&h, &s, &l);
          QColor hslColor; hslColor.setHslF(h, s, l);
          QRgb afterCol = hslColor.rgb(); //rgb --> hsl --> rgb after is 4294836480 Bug is different from before rgb
      }
      

       

      after QRgb 4294836480 equal to rgb:254, 1, 0     wrong!

      Attachments

        1. screenshot-2.png
          screenshot-2.png
          14 kB
        2. screenshot-1.png
          screenshot-1.png
          27 kB
        3. main.cpp
          0.5 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            allan.jensen Allan Sandfeld Jensen
            caocong c c
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes