Fetching RGB values of a pixel

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

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

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.