MCPcopy Index your code
hub / github.com/Audio4Linux/JDSP4Linux / colorize

Method colorize

3rdparty/qcustomplot/qcustomplot.cpp:16709–16755  ·  view source on GitHub ↗

! \overload This method is used to quickly convert a \a data array to colors. The colors will be output in the array \a scanLine. Both \a data and \a scanLine must have the length \a n when passed to this function. The data range that shall be used for mapping the data value to the gradient is passed in \a range. \a logarithmic indicates whether the data values shall be mapped to colors

Source from the content-addressed store, hash-verified

16707 with alpha (see QImage::Format_ARGB32_Premultiplied).
16708*/
16709void QCPColorGradient::colorize(const double *data, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor, bool logarithmic)
16710{
16711 // If you change something here, make sure to also adapt color() and the other colorize() overload
16712 if (!data)
16713 {
16714 qDebug() << Q_FUNC_INFO << "null pointer given as data";
16715 return;
16716 }
16717 if (!scanLine)
16718 {
16719 qDebug() << Q_FUNC_INFO << "null pointer given as scanLine";
16720 return;
16721 }
16722 if (mColorBufferInvalidated)
16723 updateColorBuffer();
16724
16725 const bool skipNanCheck = mNanHandling == nhNone;
16726 const double posToIndexFactor = !logarithmic ? (mLevelCount-1)/range.size() : (mLevelCount-1)/qLn(range.upper/range.lower);
16727 for (int i=0; i<n; ++i)
16728 {
16729 const double value = data[dataIndexFactor*i];
16730 if (skipNanCheck || !std::isnan(value))
16731 {
16732 qint64 index = qint64((!logarithmic ? value-range.lower : qLn(value/range.lower)) * posToIndexFactor);
16733 if (!mPeriodic)
16734 {
16735 index = qBound(qint64(0), index, qint64(mLevelCount-1));
16736 } else
16737 {
16738 index %= mLevelCount;
16739 if (index < 0)
16740 index += mLevelCount;
16741 }
16742 scanLine[i] = mColorBuffer.at(index);
16743 } else
16744 {
16745 switch(mNanHandling)
16746 {
16747 case nhLowestColor: scanLine[i] = mColorBuffer.first(); break;
16748 case nhHighestColor: scanLine[i] = mColorBuffer.last(); break;
16749 case nhTransparent: scanLine[i] = qRgba(0, 0, 0, 0); break;
16750 case nhNanColor: scanLine[i] = mNanColor.rgba(); break;
16751 case nhNone: break; // shouldn't happen
16752 }
16753 }
16754 }
16755}
16756
16757/*! \overload
16758

Callers 2

updateGradientImageMethod · 0.80
updateMapImageMethod · 0.80

Calls 2

sizeMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected