spectrogram: Pull out constants from pixmap tile loop

This commit is contained in:
Mike Walters
2016-06-04 16:11:25 +01:00
parent a96964bd2b
commit 702dffe441

View File

@@ -97,11 +97,11 @@ QPixmap* SpectrogramPlot::getPixmapTile(off_t tile)
float *fftTile = getFFTTile(tile);
obj = new QPixmap(linesPerTile(), fftSize);
QImage image(linesPerTile(), fftSize, QImage::Format_RGB32);
float powerRange = -1.0f / std::abs(int(powerMin - powerMax));
for (int x = 0; x < linesPerTile(); x++) {
float *line = &fftTile[x * fftSize];
for (int y = 0; y < fftSize; y++) {
float powerRange = std::abs(int(powerMin - powerMax));
float normPower = (line[y] - powerMax) * -1.0f / powerRange;
float normPower = (line[y] - powerMax) * powerRange;
normPower = clamp(normPower, 0.0f, 1.0f);
image.setPixel(x, fftSize - y - 1, colormap[(uint8_t)(normPower * (256 - 1))]);