reference from THIS
#include <QtGui>
int main(int argc, char** argv)
{
QImage image
= pixmap.
toImage();
QRgb col;
int gray;
int width = pixmap.width();
int height = pixmap.height();
for (int i = 0; i < width; ++i)
{
for (int j = 0; j < height; ++j)
{
col = image.pixel(i, j);
gray = qGray(col);
image.setPixel(i, j, qRgb(gray, gray, gray));
}
}
pixmap = pixmap.fromImage(image);
label.setPixmap(pixmap);
label.show();
return app.exec();
}
#include <QtGui>
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QPixmap pixmap("logo.png");
QImage image = pixmap.toImage();
QRgb col;
int gray;
int width = pixmap.width();
int height = pixmap.height();
for (int i = 0; i < width; ++i)
{
for (int j = 0; j < height; ++j)
{
col = image.pixel(i, j);
gray = qGray(col);
image.setPixel(i, j, qRgb(gray, gray, gray));
}
}
pixmap = pixmap.fromImage(image);
QLabel label;
label.setPixmap(pixmap);
label.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
following example convert the image into an gray scale image.
HERE:
convert the QRgb color set into a gray color.
You can use QRed, QBlue etc. according to your need.
Bookmarks