Displaying Image's Color Table
Hello experts.
Id like to know a way to display an image's color table in a QTableWidget. Let me rephrase the question, if I wanted to display the color table of an image how would I do it?
I would need the output of the color table to find colors that are in a specific range so I can manipulate those color group.
Thank you very much in advance.
Re: Displaying Image's Color Table
If we are speaking about images that do have colour tables (8 bit or less), then use QImage::colorTable() to retrieve it and create table items out of it. If the image is 24b deep, you'll need to iterate the image using QImage::pixel() and build the colour table yourself.
Re: Displaying Image's Color Table
Quote:
Originally Posted by
wysota
If we are speaking about images that do have colour tables (8 bit or less), then use
QImage::colorTable() to retrieve it and create table items out of it. If the image is 24b deep, you'll need to iterate the image using
QImage::pixel() and build the colour table yourself.
By saying building the color table myself, that means creating a color table using QImage::setColorTable() and THEN creating table items out of it?
Re: Displaying Image's Color Table
No, it means creating a QList<QColor> and filling it with colours retrieved from the image using QImage::pixel(). 24 bit images don't have colour lookup tables, because the amount of space they would take is bigger than the cost of storing the colour value directly in pixel data. At worst such a lookup table would have 16.7M entries, 3 bytes each + 3 bytes per pixel to store the index of the table in the pixel. It's better to just use 3 bytes per pixel to store the colour directly.