Hi,
Let's imagine that your image is a 8 bit image. You can create a color table like this:
for (int i=0; i<255; i++)
colortable[i] = QRgb(i,i,i);
for (int i=0; i<255; i++)
colortable[i] = QRgb(i,i,i);
To copy to clipboard, switch view to plain text mode
Displaying this image you will see a gray scale image.
Using this color table
for (int i=0; i<255; i++)
colortable[i] = QRgb(i,0,0);
for (int i=0; i<255; i++)
colortable[i] = QRgb(i,0,0);
To copy to clipboard, switch view to plain text mode
You will see a "red scale" image.
If you want a color table with only 10 indexes you have to create it as nobody knows wich output colors you expect to get. Finally, from Qt Docs:
"When the image is used, the color table must be large enough to have entries for all the pixel/index values present in the image, otherwise the results are undefined"
As your image is still having pixel values higher than 10, the output on the screen is undefined.
Bookmarks