PDA

View Full Version : color table for qimage



kernel_panic
5th April 2007, 07:06
hello all!
my problem is:
i load a bitmap from windows ntoskrnl.exe. this bitmap is cryptet (i have to set another color table to view it).
i get a pixmap and convert it to an QImage.

QImage myImage = pxm.toImage();

now i make a QVector<QRgb> mstable(16); and set the give the vector the colors i need.
then i call

myImg.setColorTable(mstable);

now i paint the image on the screen with (in paintEvent)

painter.drawImage(0,0,myImg);

but everything is black. my color table wasn't used for the image.
why, or what im making wrong?

high_flyer
5th April 2007, 12:01
now i make a QVector<QRgb> mstable(16);
But why only 16 colors?
The table has 8 bit space (256) colors.
Can you show the code where you are building the color table?

kernel_panic
5th April 2007, 13:30
the bitmap i load has only 16 colors.
i need to set up a special color table:

QVector<QRgb> mswTable(16);
mswTable.append(qRgb(0, 0, 0));
mswTable.append(qRgb(0, 0, 0));
mswTable.append(qRgb(32, 26, 21));
mswTable.append(qRgb(45, 62, 210));
mswTable.append(qRgb(83, 101, 1));
mswTable.append(qRgb(178, 53, 5));
mswTable.append(qRgb(70, 70, 70));
mswTable.append(qRgb(137, 146, 0));
mswTable.append(qRgb(94, 127, 252));
mswTable.append(qRgb(247, 107, 32));
mswTable.append(qRgb(141, 166, 255));
mswTable.append(qRgb(142, 220, 4));
mswTable.append(qRgb(243, 188, 27));
mswTable.append(qRgb(188, 188, 188));
mswTable.append(qRgb(255, 255, 255));
mswTable.append(qRgb(255, 255, 255));

high_flyer
5th April 2007, 14:30
what is the pixel depth of your bitmap?
Qt can only handle 8 or 32 bpp (not talking about QTopia now).
So if your bmp is not 8 bpp, then at best you will get a color distorded image (if anything) with your code.
If your bmp is more than 8 bpp, then you wont be able to use the color table.
At any rate, if your bmp is 8 bpp, you will have to use the 256 table, popluate the colors you are interested in, in the correct indexes, and the rest use 0 or something.
But the table it self must be a 256 indexed table.
Could you show the code where you initialize the bmp and QImage?

kernel_panic
5th April 2007, 17:44
i know now what's the really problem is.
i extract the first bitmap from ntoskrnl.exe with

HBITMAP bmp = LoadBitmap(ntoskrnl, MAKEINTRESOURCE(1));
(ntoskrnl is an instance to ntoskrnl.exe)

this HBITMAP should have only 16 colors, but somehow it has more, i can't update
an new color table or palette. i've tried it with winapi, too but it doesn't take any effect.