Why this program doesn't work?
-
Hi
This code runs with rgb colors but when i change it to cmyk , it doesn't work . why?
@ QImage image=QImage("/home/mohammad/1.jpg").scaled(ui->spinBox->value(),ui->spinBox_2->value());
int i=0 ;int j =0;for(j=0 ; j<image.width();j++) { for(i=0;i<image.height();i++) { QColor color=QColor::fromCmyk(image.pixel(i,j)); ui->plainTextEdit->appendPlainText(QString("cyan is : ") + QString::number(color.cyan()) + QString("magenta is: ") + QString::number(color.magenta()) + QString("yellow is:") + QString::number(color.yellow()) + QString("black is") +QString::number(color.black()));
}
}@this is the error : no matching function for call to "QColor::fromCmyk(Qrgb);
-
Why would you expect that a method called "fromCymk" will accept a RGB value? Just looking at the name I would expect that method to require a CYMK value.
Try "fromRgb" to turn the Rgb value into a QColor.
-
[quote author="Tobias Hunger" date="1367692122"]Why would you expect that a method called "fromCymk" will accept a RGB value? Just looking at the name I would expect that method to require a CYMK value.
Try "fromRgb" to turn the Rgb value into a QColor.[/quote]
cause I want to rich cmyk values of an image!
Is it possible? how? -
You have to do a color space conversion from RGB to CMYK, QColor has functions for that
-
I solved it by adding toCmyk() function after this line :
@QColor color=QColor::fromRgb(image.pixel(i,j)).toCmyk();@
and so changing fromCmyk to fromRgb
and the program is working , but i am not sure the returns value are true ?!
-
What do you mean by true ?
-
i would assume he meant true = correct (not true as a boolean value).
-
I would in the first place but there is also the notion of "true color", that's why I asked