You don't have pixel access in QPixmap
, so going over the pixels and darkening them is out of the question.
You can however fill a pixmap with a transparent black brush, and use a number of composition modes to further customize the result.
QPainter painter(this);
QPixmap pm("d:/test.jpg");
painter.drawPixmap(QRect(0, 0, 400, 200), pm);
painter.translate(0, 200);
painter.drawPixmap(QRect(0, 0, 400, 200), pm);
painter.fillRect(QRect(0, 0, 400, 200), QBrush(QColor(0, 0, 0, 200)));
Run Code Online (Sandbox Code Playgroud)