Search code examples
qtpixelhslqcolor

QColor Hot to get darker image (array of pixels) in qt creator (using function darker)?


Hi i have a simple question: I need to make darker a image (array of them), by converting rgb to hsl and back. This is my code (just reading pixel by pixel and send it to console):

for (int y=0 ; y<32 ; y++) {
  for (int x=0 ; x<32 ; x++) {
      QColor color=QColor::darker(300); // there is wrong :( little help pls
      QColor color(image.pixel(x, y));
      uint red = color.red(); uint green = color.green(); uint blue = color.blue();
      qDebug() << red << green << blue;
    }
}

Function description is Here

Info: QColor ilb for Qt Creator for editing images.


Solution

  • darker() is a member function, you need to invoke it from a color instance:

    QColor color = someColor.darker(300);
    

    You also declare a QColor color twice.