Results 1 to 3 of 3

Thread: How do i display the rgb value of a pixel

  1. #1
    Join Date
    May 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default How do i display the rgb value of a pixel

    Hi
    Could anyone tell me how to display the rgb pixel values of a qimage that has the format of QImage::Format_RGB32. So far i tried this

    QImage* image = new QImage("/images/testimg.jpg");

    cout << image->format(); // gives the value 4

    for(int y=0; y < image->height(); y++)
    {
    QRgb val = image->pixel(0, y);
    cout << " rgb value = " << val << endl;
    }

    After i get the proper values i will iterate over and x and y but with this im only seeing values like this

    rgb value = 4294043701 and when using an image app like gimp and looking at the first pixel value things dont match up. Should these be rgb values between 0-255, what am i missing here? Thanks

  2. #2
    Join Date
    Dec 2006
    Location
    Kędzierzyn-Koźle
    Posts
    16
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How do i display the rgb value of a pixel

    Try to use
    cout<<qRed(val)<<","<<qGreen(val)<<","<<qBlue(val) <<endl;

  3. #3
    Join Date
    May 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How do i display the rgb value of a pixel

    Thank you very much that was what i needed!

Similar Threads

  1. synchronise QLabel display and webcam capture
    By fbmfbm in forum Qt Programming
    Replies: 2
    Last Post: 24th February 2009, 11:10
  2. OS/X how to get physical display handle
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 3rd January 2009, 19:51
  3. Display only PNG image on desktop
    By durbrak in forum Qt Programming
    Replies: 32
    Last Post: 15th March 2008, 21:55
  4. QPixmap pixel by pixel ?
    By tommy in forum Qt Programming
    Replies: 19
    Last Post: 3rd December 2007, 22:52
  5. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08

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.