BUG? QColor::fromCmyk() produces dark output

  • Hi! I am working on my project, "libqpsd":https://github.com/Code-ReaQtor/libqpsd

    Currently I am on the CMYK color mode. I found something odd in the "QColor::fromCmyk()":http://qt-project.org/doc/qt-4.8/qcolor.html#fromCmyk

    The output produced has inverted colors (black becomes white, white becomes black).

    I was able to correct it by using this:
    @QColor color = QColor::fromCmyk(255-cyan, 255-magenta,255-yellow, 255-key);
    //cyan, magenta, yellow, key are all quint8 taken from QDatastream@

    but I am not satisfied since it should be like this, AFAIK:
    @QColor color = QColor::fromCmyk(cyan, magenta, yellow, key);@

    EDIT: I am using QColor::rgb() to convert it to RGB

    Is this a BUG in the QColor class?

  • It's not a bug, it's intended. CMY are the basic colors of the "subtractive color system":http://en.wikipedia.org/wiki/Subtractive_color that is usually used to print on white backgrounds so more color means darker and less color means lighter and that is the exact opposite of what happens using RGB as base colors to paint on a black background

  • Thanks VRonin, I understand what CMYK is.

    But was QColor::rgb(), "supposedly", convert it to the right RGB (light) color and not retaining the CMYK style (dark)?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.