#include <QtGui>
#include <QtCore>
#include <QCoreApplication>
int main(int argc, char *argv[])
{
for (int y = 0; y < base.height(); ++y) {
for (int x = 0; x < base.width(); ++x) {
int pixel = base.pixel(x, y);
int gray = qGray(pixel);
int alpha = qAlpha(pixel);
base.setPixel(x, y, qRgba(gray, gray, gray, alpha));
}
}
QPixmap xnew
(base.
width(),base.
height());
xnew.fill();
/* paint B/W */
painter.begin(&xnew);
painter.
setRenderHint(QPainter::Antialiasing);
painter.
drawImage(0,
0,
QImage("test.png"));
painter.drawImage(base.width() / 2,0,base);
painter.end();
label->setPixmap(xnew);
label->show();
return app.exec();
}
#include <QtGui>
#include <QtCore>
#include <QCoreApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello Picasso");
QPixmap bw = QPixmap("test.png");
QImage base0("test.png");
QImage base = base0.convertToFormat(QImage::Format_RGB32);
for (int y = 0; y < base.height(); ++y) {
for (int x = 0; x < base.width(); ++x) {
int pixel = base.pixel(x, y);
int gray = qGray(pixel);
int alpha = qAlpha(pixel);
base.setPixel(x, y, qRgba(gray, gray, gray, alpha));
}
}
QPixmap xnew(base.width(),base.height());
xnew.fill();
/* paint B/W */
QPainter painter;
painter.begin(&xnew);
painter.setRenderHint(QPainter::Antialiasing);
painter.drawImage(0,0,QImage("test.png"));
painter.drawImage(base.width() / 2,0,base);
painter.end();
label->setPixmap(xnew);
label->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks