2
creates an image of the spectrum analyser peaks
3
Copyright (C) 1998 Martin Vogt
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation.
9
For more information look at the file COPYRIGHT in this package
14
#include <spectrumImage.h>
19
SpectrumImage::SpectrumImage(int height, int width) {
22
qPixmap=new QPixmap(width,height);
26
SpectrumImage::~SpectrumImage() {
32
QPixmap* SpectrumImage::getPixmap() {
37
int SpectrumImage::getHeight() {
41
void SpectrumImage::fillImage(float *data) {
45
float colorHeight=(float)height/5.0;
48
painter.begin(qPixmap);
50
// draw the first entry
54
// now draw the rest 1..
55
/* for(col=0;col<width;col++) {
56
// first draw the black part
57
for(row=0;row<height-col;row++) {
58
painter.setPen(QColor(0,0,0));
59
painter.drawPoint(col,row);
62
for(row=width-col;row<height;row++) {
63
// now we must creat a smooth gradient from red to yellow to green
64
if (currentRow < 0.4*colorHeight) {
65
float x=(float)currentRow/(5.0*colorHeight);
70
painter.setPen(QColor(208.0-a,39.0+b,c));
71
} else if (currentRow < 1.2*colorHeight) {
72
float x=(float)currentRow/(5.0*colorHeight);
77
painter.setPen(QColor(192.0+a,120.0+b,c));
78
} else if (currentRow < 2.2*colorHeight) {
79
float x=(float)currentRow/(5.0*colorHeight);
84
painter.setPen(QColor(191.0-a,223.0,32));
85
} else if (currentRow < 3.0*colorHeight) {
86
float x=(float)currentRow/(5.0*colorHeight);
91
painter.setPen(QColor(32.0+a,207.0-b,15));
92
} else if (currentRow < 5*colorHeight) {
93
float x=(float)currentRow/(5.0*colorHeight);
98
painter.setPen(QColor(47.0,152.0,0));