automatic scale for the color based on the max power values
This commit is contained in:
parent
228fc3ab24
commit
bba7a481ad
@ -45,3 +45,19 @@ bool DisplayArea::saveImage(const QString &fileName, const char *fileFormat)
|
||||
{
|
||||
return image.save(fileName, fileFormat);
|
||||
}
|
||||
|
||||
void DisplayArea::updateColorMap(float oldMin, float oldMax, float newMin, float newMax)
|
||||
{
|
||||
QRgb* imagePixels=(QRgb*)image.bits();
|
||||
for(unsigned long long i=0;i<image.sizeInBytes()/sizeof(QRgb);i++){
|
||||
QRgb currentColor=imagePixels[i];
|
||||
QRgb newColor=qRgba(remap(qRed(currentColor),oldMin,oldMax,newMin,newMax),remap(qGreen(currentColor),oldMin,oldMax,newMin,newMax),remap(qBlue(currentColor),oldMin,oldMax,newMin,newMax),qAlpha(currentColor));
|
||||
imagePixels[i]=newColor;
|
||||
}
|
||||
}
|
||||
|
||||
char DisplayArea::remap(char c, float omin, float omax, float nmin, float nmax)
|
||||
{
|
||||
float nVal=(255*(omin-nmin)+c*(omax-omin))/(nmax-nmin);
|
||||
return qRound(nVal);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ public:
|
||||
DisplayArea(QWidget *parent = nullptr);
|
||||
void setPixel(int x,int y,unsigned int col);
|
||||
bool saveImage(const QString &fileName, const char *fileFormat);
|
||||
void updateColorMap(float oldMin,float oldMax,float newMin,float newMax);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
@ -17,6 +18,8 @@ protected:
|
||||
private:
|
||||
void resizeImage(QImage *image, const QSize &newSize);
|
||||
|
||||
char remap(char val,float omin,float omax,float nmin,float nmax);
|
||||
|
||||
QImage image;
|
||||
|
||||
public slots:
|
||||
|
@ -123,7 +123,18 @@ void InputParser::computeEpochDate()
|
||||
void InputParser::sendPixel()
|
||||
{
|
||||
currentPowerValue*=sign;
|
||||
int col=qRound((80-currentPowerValue)*6);
|
||||
|
||||
if(currentPowerValue<minPow||currentPowerValue>maxPow){
|
||||
float newMin=qMin(currentPowerValue,minPow);
|
||||
float newMax=qMax(currentPowerValue,maxPow);
|
||||
|
||||
display->updateColorMap(minPow,maxPow,newMin,newMax);
|
||||
|
||||
minPow=newMin;
|
||||
maxPow=newMax;
|
||||
}
|
||||
|
||||
int col=qRound(currentPowerValue-minPow)*255/(maxPow-minPow);
|
||||
display->setPixel(currentX,currentY,qRgba(col,col,col,255));
|
||||
currentX++;
|
||||
currentPowerValue=0;
|
||||
|
@ -28,6 +28,9 @@ private:
|
||||
unsigned long minFreq=-1;
|
||||
unsigned long maxFreq=0;
|
||||
|
||||
float minPow=__FLT_MAX__;
|
||||
float maxPow=0;
|
||||
|
||||
unsigned long lastMaxFreq=0;
|
||||
|
||||
unsigned long index=0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user