Hi friends,
I can not change the format of an image.
I want the image has only 8 bits, only 256 colors, but any changes will not work.
I tried setNumColors(), convertToFormat(), and not work.
Code:
What the possible problem?
Printable View
Hi friends,
I can not change the format of an image.
I want the image has only 8 bits, only 256 colors, but any changes will not work.
I tried setNumColors(), convertToFormat(), and not work.
Code:
What the possible problem?
What is 'fn'?
Are you sure that imageF is a valid Image?
If you do the following:
Code:
What do you get in 'format'?
fn is the filename.
imageF is ok.
The conversion is ok, the format is 3 (Format_Indexed8).
But I want an image to grayscale representation of 8 bits (256 colors).
I'm doing "valuePixel = (qRed(imageF.pixel(1,1)) + qGreen(imageF.pixel(1,1)) + qBlue(imageF.pixel(1,1)))/3;" to get the value of each pixel.
But I think it's possible before turning the image into grayscale 8-bit.
Try building a 256 element grey colour table and then call the variant of QImage::convertToFormat() that takes a colour table and build an indexed image that way.
If you want to do it manually then look at qGray(). Your simple average of R, G, and B values is not a good reflection of the perceived brightness of colours.