Results 1 to 4 of 4

Thread: Displaying Image's Color Table

  1. #1
    Join Date
    Dec 2007
    Posts
    32
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.

  3. #3
    Join Date
    Dec 2007
    Posts
    32
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Displaying Image's Color Table

    Quote Originally Posted by wysota View Post
    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?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.

Similar Threads

  1. Replies: 3
    Last Post: 17th May 2007, 13:50
  2. Displaying real time images
    By Sheetal in forum Qt Programming
    Replies: 9
    Last Post: 22nd February 2007, 11:29

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.