I can't seem to find a default or any provided colormap in Qt
(5.7 in my case).
All I find is people generating their own color table such as:
QVector<QRgb> ctable;
for(int i = 0; i < 256; ++i)
{
ctable.append(qRgb(i,i,i));
}
So is there any colormap available in Qt
(as there is in matplotlib or matlab like here ?
Edit: a colormap to go with QImage::Format_Indexed8
image format and QImage::setColorTable()
A solution, as Qt does not provide any colormap:
I downloaded a colormap from AMA's link http://www.kennethmoreland.com/color-advice/black-body/black-body-table-byte-0256.csv
Then I read the file to generate my own colormap:
QVector<QRgb> ctable;
QFile file("black-body-table-byte-0128.csv");
if(!file.open(QIODevice::ReadOnly))
{
QMessageBox::information(0, "error", file.errorString());
}
QTextStream in(&file);
while(!in.atEnd())
{
QString line = in.readLine();
QStringList values = line.split(",");
ctable.append(qRgb(values[1].toInt(), values[2].toInt(), values[3].toInt()));
}
file.close();
now ctable
can be used as a colormap using:
QImage myImage;
myImage.setColorTable(ctable);
No, unfortunately Qt does not provide any. You will have to build it yourself. But there are plenty of sources with color table values for all sorts of needs.
Edit: I successfully used some perceptually uniform colormaps from http://www.kennethmoreland.com for my data visualization needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With