Commit f35496cf authored by Halla Rempt's avatar Halla Rempt
Browse files

Use allGray instead of isGrayScale to determine whether the brush tip is grayscale

This works around a bug in QImage::isGrayScale where images with
16 bits/channel are not checked with allGray, so by default are not
grayscale. These images have depth 64, which is not in the switch
statement:

bool QImage::isGrayscale() const
{
    if (!d)
        return false;

    if (d->format == QImage::Format_Alpha8)
        return false;

    if (d->format == QImage::Format_Grayscale8)
        return true;

    switch (depth()) {
    case 32:
    case 24:
    case 16:
        return allGray();
    case 8: {
        Q_ASSERT(d->format == QImage::Format_Indexed8);
        for (int i = 0; i < colorCount(); i++)
            if (d->colortable.at(i) != qRgb(i,i,i))
                return false;
        return true;
        }
    }
    return false;
}

BUG:405693
parent 1fd41188
...@@ -106,7 +106,7 @@ bool KisPngBrush::loadFromDevice(QIODevice *dev) ...@@ -106,7 +106,7 @@ bool KisPngBrush::loadFromDevice(QIODevice *dev)
setBrushTipImage(image); setBrushTipImage(image);
setValid(true); setValid(true);
if (brushTipImage().isGrayscale()) { if (brushTipImage().allGray()) {
setBrushType(MASK); setBrushType(MASK);
setHasColor(false); setHasColor(false);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment