Reconsider alpha channel with the QwtColorMap
Brought to you by:
rathmann
|
From: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - 2014-12-04 09:42:40
|
Hi, I think the alpha channel is silently discarded when using the base class' virtual QwtColorMap::color. The interpolated Qrgb quadrupel is converted to a QColor using the QColor::QColor(QRgb) c-tor, which in turn resets the alpha channel to opaque. QColor::fromRgba would be more appropriate there, I suppose. Yours, Sven Old message from the bug tracker: The QwtAlphaColorMap provides an alpha channel that virtually gets munched at every use case except for the QwtPlotSpectogram (where scanLine is manipulated directly). Although there is QwtAlphaColorMap::color() which returns a QRgb with the alpha channel set, it is not defined virtual so the base class' QwtColorMap::color() is used instead and tosses the alpha channel by using QColor::QColor(QRgb). Also, the alpha channel is discarded when drawing with QwtPainter::drawColorBar, QwtThermo::drawLiquid and QwtPlotSpectroCurve::drawDots because in the respective drawing routines, the Rgb quadruple returned by the color map is converted to a QColor using the QColor::QColor(QRgb) c-tor, which silently returns opaque colors. Maybe the base class QwtColorMap should be producing true rgba quadruples instead. In the respecitive use cases, instead of the above mentioned c-tor, use QColor::fromRgba (QColor::setRgba in QwtThermo::drawLiquid) instead. The alpha channel comes handy for a more modern look and feel as it allows, e.g. the liquid or the color bar of the plot scale widget to integrate into the widget's background. Yet, I am just tinkering. I cannot tell if this would have any bad impact on performance. In fact, Qt seems to usually draw using the (fully opaque) alpha channel anyway. |