16 QImage imgTemp = imgOrig.convertToFormat(QImage::Format_ARGB32);;
17 qint32 nHeight = imgTemp.height();
18 qint32 nWidth = imgTemp.width();
20 for (qint32 y = 0; y < nHeight; ++y) {
21 QRgb* tempLine =
reinterpret_cast<QRgb*
>(imgTemp.scanLine(y));
23 for (qint32 x = 0; x < nWidth; ++x) {
24 int r = qRed(*tempLine) + n;
25 int g = qGreen(*tempLine) + n;
26 int b = qBlue(*tempLine) + n;
27 int a = qAlpha(*tempLine);
29 *tempLine++ = qRgba(r > 255 ? 255 : r < 0 ? 0 : r,
30 g > 255 ? 255 : g < 0 ? 0 : g,
31 b > 255 ? 255 : b < 0 ? 0 : b,
41 int main(
int argc,
char** argv)
43 QApplication app(argc, argv);
44 QImage img(
":/happyos.png");
47 QHBoxLayout* phbx =
new QHBoxLayout;
50 for (
int i = -150; i < 150; i += 50) {
51 QLabel* plbl =
new QLabel;
52 plbl->setFixedSize(img.size());
53 QPixmap pix = QPixmap::fromImage(
brightness(img, i));
55 phbx->addWidget(plbl);
int main(int argc, char **argv)
QImage brightness(const QImage &imgOrig, int n)