Skip to content

BUG: wrong canvas border color

I noticed that the canvas border color was off: you selected blue (#0000FF), it displayed red (#FF0000). Then, I found an issue in the mapping from KoColor's internal data representation to the RGB components for an OpenGL call.

The way the internal data was being used assumed it was in the order RGBA:

        QVector<float> channels = QVector<float>(4);
        convertedBackgroudColor.colorSpace()->normalisedChannelsValue(convertedBackgroudColor.data(), channels);
        glClearColor(channels[0], channels[1], channels[2], 1.0);

But if you look at the implementation of the KoRgbU8ColorSpace color space (which is the one used in those lines) you'll see the internal data is stored as BGRA:

void KoRgbU8ColorSpace::fromQColor(const QColor& c, quint8 *dst, const KoColorProfile * /*profile*/) const
{
    QVector<float> channelValues;
    channelValues << c.blueF() << c.greenF() << c.redF() << c.alphaF();
    fromNormalisedChannelsValue(dst, channelValues);
}

So I changed the order of the color components in the call to OpenGL.

Test Plan

To reproduce the issue:

  • Go to Settings > Configure Krita... > Display > Grid Settings
  • Change the "Canvas Border Color" to some red like #FF0102.
  • Upon saving, the background color won't turn red but blue (exactly #0201FF).
  • Please note, if this other bugfix has not been merged yet, then you need to do Settings > Configure Krita... again and, without changing anything, click "OK" to see the canvas color changing to blue.

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.

Merge request reports