Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Fetching RGB values of a pixel
Qt 6.11 is out! See what's new in the release blog

Fetching RGB values of a pixel

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    christopher09
    wrote on last edited by
    #1

    I am trying to fetch RGB values of a pixel using the following method

    @QRgb nil=image.pixel(x,y);
    QColor fin(nil);
    int r,g,b;
    r = v.red();
    g = v.green();
    b = v.blue(); @

    This is is giving out of range exception for the given pixel coordinates though they are valid. I am I doing it right ? Can some one tell the best way to fetch rgb values of a pixel if the above isn't.
    Thanks

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      Try this:
      @QRgb nil=image.pixel(x,y);
      int r,g,b;
      r = qRed (nil);
      g = qGreen (nil);
      b = qBlue ( nil);@

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved