~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to noatun/noatun/modules/winskin/spectrumImage.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  creates an image of the spectrum analyser peaks
 
3
  Copyright (C) 1998  Martin Vogt
 
4
 
 
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.
 
8
 
 
9
  For more information look at the file COPYRIGHT in this package
 
10
 
 
11
 */
 
12
 
 
13
 
 
14
#include <spectrumImage.h>
 
15
 
 
16
 
 
17
 
 
18
 
 
19
SpectrumImage::SpectrumImage(int height, int width) {
 
20
  this->height=height;
 
21
  this->width=width;
 
22
  qPixmap=new QPixmap(width,height);
 
23
}
 
24
 
 
25
  
 
26
SpectrumImage::~SpectrumImage() {
 
27
  delete qPixmap;
 
28
}
 
29
 
 
30
 
 
31
 
 
32
QPixmap* SpectrumImage::getPixmap() {
 
33
  return qPixmap;
 
34
}
 
35
 
 
36
 
 
37
int SpectrumImage::getHeight() {
 
38
  return height;
 
39
}
 
40
 
 
41
void SpectrumImage::fillImage(float *data) {
 
42
  QPainter painter;
 
43
  int row;
 
44
  int col;
 
45
  float colorHeight=(float)height/5.0;
 
46
  int currentRow=0;
 
47
 
 
48
  painter.begin(qPixmap);
 
49
 
 
50
  // draw the first entry
 
51
 
 
52
 
 
53
 
 
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);
 
60
    }
 
61
    currentRow=0;
 
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);
 
66
        float a=x;
 
67
        float b=73.0*x;
 
68
        float c=15.0*x;
 
69
 
 
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);
 
73
        float a=16.0*x;
 
74
        float b=56.0*x;
 
75
        float c=31.0*x;
 
76
 
 
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);
 
80
        float a=47.0*x;
 
81
        float b=56.0*x;
 
82
        float c=31.0*x;
 
83
        
 
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);
 
87
        float a=16.0*x;
 
88
        float b=31.0*x;
 
89
        float c=31.0*x;
 
90
        
 
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);
 
94
        float a=16.0*x;
 
95
        float b=31.0*x;
 
96
        float c=31.0*x;
 
97
        
 
98
        painter.setPen(QColor(47.0,152.0,0));
 
99
      }
 
100
 
 
101
    }
 
102
  }
 
103
  */
 
104
  painter.end();
 
105
}
 
106