Results 1 to 5 of 5

Thread: color table for qimage

  1. #1
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question color table for qimage

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: color table for qimage

    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?

  3. #3
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: color table for qimage

    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));

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: color table for qimage

    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?

  5. #5
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: color table for qimage

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.