/*************************************************************************** * Copyright (C) 2011 by gempa GmbH * * Author: Jan Becker * Email: jabe@gempa.de ***************************************************************************/ #ifndef __GEMPA_SPECTROGRAM_IMAGE_H__ #define __GEMPA_SPECTROGRAM_IMAGE_H__ #include #include #include #include namespace Gempa { namespace Gui { template class Spectrogram; typedef Gempa::Utils::LUT ColorLUT; template class StaticColorLUT : public Gempa::Utils::StaticLUT { public: StaticColorLUT() {} StaticColorLUT(const Seiscomp::Gui::Gradient &gradient) { generateFrom(gradient); } public: bool setRangeFrom(const Seiscomp::Gui::Gradient &gradient) { if ( gradient.empty() ) return false; double lower = gradient.begin().key(); double upper = (--gradient.end()).key(); Gempa::Utils::StaticLUT::setRange(lower, upper); return true; } void generateFrom(const Seiscomp::Gui::Gradient &gradient) { if ( !setRangeFrom(gradient) ) return; for ( int i = 0; i < N; ++i ) Utils::StaticLUT::_staticLUT[i] = gradient.colorAt(Utils::StaticLUT::indexToKey(i)).rgba(); } }; template bool generateImageCW(QImage &img, const Spectrogram *spec, const ColorLUT *lut, int width, int height, int columnOffset = 0, int columnWidth = -1); template bool generateImagePPS(QImage &img, const Spectrogram *spec, const ColorLUT *lut, int width, int height, int columnOffset = 0, double pixelPerSecond = 1.0); } } #endif