[Interest] QImage::Format_Grayscale8 work working

Nikolai Tasev nikolai at nand.bg
Fri Mar 16 15:28:56 CET 2018


Sorry a typo qRgb(qRed(rgbVal), qRed(rgbVal), qRed(rgbVal)) for setting 
the pixel on the red channel

On 3/16/2018 4:25 PM, Nikolai Tasev wrote:
> Yes that confirms my suspicions that setPixel for Format_Grayscale8 
> expect different things ( as I wrote in my previous email).
> You need to pass qRgb(qRed(rgbVal), 0, 0) for red, not qRed(rgbVal).
>
> On 3/16/2018 4:09 PM, Jason H wrote:
>> 5.10.1
>>
>> Yes, that's a good idea. So I wrote some code:
>>
>>     QImage gray8 = color8(image, Qt::gray, 
>> QImage::Format_Grayscale8); // modded my function to take the format.
>>     QImage index = color8(image, Qt::gray, QImage::Format_Indexed8);
>>
>>     int differences = 0;
>>     int same = 0;
>>     for (int y=0; y < gray8.height(); y++) {
>>         for (int x=0; x < gray8.width(); x++) {
>>             qDebug() << "gray" << gray8.pixel(x,y) << "index" << 
>> index.pixel(x,y);
>>             if (gray8.pixel(x,y) != index.pixel(x,y) )
>>                 differences++;
>>             else
>>                 same++;
>>         }
>>     }
>>
>>     qDebug() << "differences" <<  differences;
>>     qDebug() << "same" <<  same;
>>
>> With output:
>> differences 8048393
>> same 72951
>>
>> It seems every pixel from "gray8" is 4278190080 == 0xFF000000.
>> So it seems that setPixel in my color8 function never sets the pixel.
>>
>> I'm thinking this is a bug, unless someone has an idea?




More information about the Interest mailing list