How to paint color on gray image !
-
Hi,
How to paint color on gray image ! I tried like this, but the end result is still Gray image
Can someone help me?
Thanks!QImage img= QImage((const unsigned char*)(videoFrame.data), videoFrame.cols,videoFrame.rows, QImage::Format_Grayscale8); // format Gray QPainter painter; QBrush brush=QBrush(QColor(Qt::red)); // I need paint color on gray image (img) painter.begin(&img); painter.fillRect(0,0,100,100,brush); painter.end(); ui->label_2->setPixmap(QPixmap::fromImage(img));
-
Hi,
How to paint color on gray image ! I tried like this, but the end result is still Gray image
Can someone help me?
Thanks!QImage img= QImage((const unsigned char*)(videoFrame.data), videoFrame.cols,videoFrame.rows, QImage::Format_Grayscale8); // format Gray QPainter painter; QBrush brush=QBrush(QColor(Qt::red)); // I need paint color on gray image (img) painter.begin(&img); painter.fillRect(0,0,100,100,brush); painter.end(); ui->label_2->setPixmap(QPixmap::fromImage(img));
-
Dear Mr. @ollarch
Is this what you mean? I tried it, and it's red, but the original gray (img) image is lostQImage img= QImage((const unsigned char*)(videoFrame.data), videoFrame.cols,videoFrame.rows, QImage::Format_Grayscale8); // format Gray QImage img2{img.size(), QImage::Format_RGB888}; // convert to RGB QPainter painter; QBrush brush=QBrush(QColor(Qt::red)); // I need paint color on gray image (img) painter.begin(&img2); painter.fillRect(0,0,100,100,brush); painter.end(); ui->label_2->setPixmap(QPixmap::fromImage(img2));
-
start with an RGB colorspace image and rectfill it with the RGB values that would make it grey, then overlay any other colors you want, where you want.
-
D DQUY05 has marked this topic as solved on