[SOLVED]Image color Convert, stumbling upon answer
[Solved]
Changed from QLabel to QGraphicsView
Code:
QGraphicsColorizeEffect *effect;
effect = new QGraphicsColorizeEffect;
effect
->setColor
(QColor(Qt
::red));
Apologies for any inconvenience
Next time will do my homework better before posting
Apologies
Kind Regards
-----------------------------------------------------------------------------------------------------------------------------
This is a similar thread to others, but not the same!
I was initially trying to convert an image to gray scale
when my code instead of converting everything to grayscale
took a black & white image kept the black as is & converted the the white to dark blue----> fantastic
Thats actually what i needed, the thing is how do I change what colour should the white be converted to?
because technically my code does not specify blue!
Code:
image1
= image1.
convertToFormat(QImage::Format_RGB32);
QRgb color;
for (int i=0; f1<image1.width(); i++) {
for (int j=0; j<image1.height(); j++) {
color = image1.pixel(i, j);
image1.
setPixel(i, j,
QColor((qRed
(color
) + qGreen
(color
) + qBlue
(color
))/3).
rgb());
}
}
Whenever i put the above code i my program it converts all white to blue :confused:
Initially i wanted grayscale but im more than happy with this result
though I want to choose which color
Ideas please
Kind Regards
Re: Image color Convert, stumbling upon answer
How is the code you posted related to what you have written in the description?
Re: Image color Convert, stumbling upon answer
I just started with Qt, but shouldn't line 4 be:
Code:
for (int i=0; i < image1.width(); i++)
Re: Image color Convert, stumbling upon answer
[Solved]
Changed from QLabel to QGraphicsView
Code:
QGraphicsColorizeEffect *effect;
effect = new QGraphicsColorizeEffect;
effect
->setColor
(QColor(Qt
::red));
Apologies for any inconvenience
Next time will do my homework better before posting
Kind Regards:)
Re: Image color Convert, stumbling upon answer
You can apply the colorize effect to the label as well.