Results 1 to 14 of 14

Thread: Explanation to Image Formats

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Explanation to Image Formats

    Could you try with a different file? For example the one attached. The application won't work for 8 bit (indexed) images like qt-logo.
    Attached Images Attached Images

  2. The following user says thank you to wysota for this useful post:

    sincnarf (6th July 2007)

  3. #2
    Join Date
    Apr 2007
    Posts
    117
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    84
    Thanked 1 Time in 1 Post

    Default Re: Explanation to Image Formats

    Thank you both wysota and jacek! wysota's sample program worked for the attached image kdmconfig.png!

    Just as I thought I need to know what valid image conversions I should use.

    @wysota, what do i need to do in order to pattern other images to the properties of kdmconfig.png. Can you give me the exact properties of that attached kdmconfig? I opened it in Adobe Photoshop CS2 and I saw that the image's mode is "RGB Color", "8 bits / channel", and bit depth = "32". What other pertinent information am I missing?

    @jacek, in QImage::setColorTable ( const QVector<QRgb> colors ), what is "QVector<QRgb> colors"? Is that where I set my gray color?

    Separate question: By the way how much maximum colors can QImage support? Is it 256? Thanks in advance for all the advice! Thank God I saw QtCentre.org!

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

    Default Re: Explanation to Image Formats

    Quote Originally Posted by sincnarf View Post
    what do i need to do in order to pattern other images to the properties of kdmconfig.png.
    They should be True or Full Color, not indexed. With indexed images (ones that have the color lookup table) you just need to change the contents of the lookup table without touching actual pixels.

    Can you give me the exact properties of that attached kdmconfig?
    kdmconfig.png: PNG image data, 128 x 128, 8-bit/color RGBA, non-interlaced

    in QImage::setColorTable ( const QVector<QRgb> colors ), what is "QVector<QRgb> colors"? Is that where I set my gray color?
    Yes, for indexed images.

    Separate question: By the way how much maximum colors can QImage support? Is it 256?
    16777216 (2^24). Multiplied by 256 if you also count different alpha values which then gives 4294967296 (4G) colours.

  5. The following user says thank you to wysota for this useful post:

    sincnarf (4th October 2007)

  6. #4
    Join Date
    Apr 2007
    Posts
    117
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    84
    Thanked 1 Time in 1 Post

    Default Re: Explanation to Image Formats

    hmmm. definitely got the "non-interlaced" advice. Is this how you use setColorTable method?

    Qt Code:
    1. int gray = 0;
    2. int pixel = 0;
    3. image.setNumColors(256);
    4. QVector<QRgb> colorTable(256);
    5. for (x= 0; x < image.width(); x++){
    6. for (y = 0; y < image.height(); y++){
    7. pixel = image.pixel(x, y);
    8. gray = qGray(pixel);
    9. colorTable.append(qRgb(gray, gray, gray));
    10. }
    11. }
    12. image.setColorTable(colorTable);
    To copy to clipboard, switch view to plain text mode 

  7. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Explanation to Image Formats

    Quote Originally Posted by sincnarf View Post
    Is this how you use setColorTable method?
    No, get the original colour table using QImage::colorTable(), replace all of the entries with grayscale equivalents and set the new colour table using QImage::setColorTable(), but only if the image has a colour table (i.e. QImage::numColors() is greater than 0).

  8. The following user says thank you to jacek for this useful post:

    sincnarf (4th October 2007)

Similar Threads

  1. Help needed handling image data
    By toratora in forum General Programming
    Replies: 2
    Last Post: 11th May 2007, 09:24
  2. custom widgets painting image formats
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2007, 10:33
  3. how i can add image in my toolbar
    By jyoti in forum Qt Tools
    Replies: 7
    Last Post: 19th December 2006, 14:39
  4. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36
  5. Question about updating an image on screen
    By SkripT in forum Qt Programming
    Replies: 1
    Last Post: 24th February 2006, 19:01

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
  •  
Qt is a trademark of The Qt Company.