1.1 --- a/Server/Spectrum/LineSpectrum.cs Wed Jan 04 18:43:28 2017 +0100
1.2 +++ b/Server/Spectrum/LineSpectrum.cs Thu Jan 05 14:54:43 2017 +0100
1.3 @@ -77,28 +77,21 @@
1.4 return SpectrumProvider.GetFftData(iFftBuffer, this);
1.5 }
1.6
1.7 - public Bitmap CreateSpectrumLine(Size size, Brush brush, Color background, bool highQuality)
1.8 + private bool CreateSpectrumLine(Image aImage, Brush brush, Color background, bool highQuality)
1.9 {
1.10 - if (!UpdateFrequencyMappingIfNessesary(size))
1.11 - {
1.12 - return null;
1.13 - }
1.14 -
1.15 //get the fft result from the spectrum provider
1.16 using (var pen = new Pen(brush, (float)_barWidth))
1.17 {
1.18 - var bitmap = new Bitmap(size.Width, size.Height);
1.19 -
1.20 - using (Graphics graphics = Graphics.FromImage(bitmap))
1.21 + using (Graphics graphics = Graphics.FromImage(aImage))
1.22 {
1.23 PrepareGraphics(graphics, highQuality);
1.24 graphics.Clear(background);
1.25
1.26 - CreateSpectrumLineInternal(graphics, pen, iFftBuffer, size);
1.27 + CreateSpectrumLineInternal(graphics, pen, iFftBuffer, aImage.Size);
1.28 }
1.29 + }
1.30
1.31 - return bitmap;
1.32 - }
1.33 + return true;
1.34 }
1.35
1.36 /// <summary>
1.37 @@ -110,21 +103,26 @@
1.38 /// <param name="background"></param>
1.39 /// <param name="highQuality"></param>
1.40 /// <returns></returns>
1.41 - public Bitmap Render(Size size, Color color1, Color color2, Color background, bool highQuality)
1.42 + public bool Render(Image aImage, Color color1, Color color2, Color background, bool highQuality)
1.43 {
1.44 - if (!UpdateFrequencyMappingIfNessesary(size))
1.45 + if (!UpdateFrequencyMappingIfNessesary(aImage.Size))
1.46 {
1.47 - return null;
1.48 + return false;
1.49 }
1.50
1.51 - using (
1.52 - Brush brush = new LinearGradientBrush(new RectangleF(0, 0, (float)_barWidth, size.Height), color2,
1.53 - color1, LinearGradientMode.Vertical))
1.54 + using (Brush brush = new LinearGradientBrush(new RectangleF(0, 0, (float)_barWidth, aImage.Size.Height), color2, color1, LinearGradientMode.Vertical))
1.55 {
1.56 - return CreateSpectrumLine(size, brush, background, highQuality);
1.57 + return CreateSpectrumLine(aImage, brush, background, highQuality);
1.58 }
1.59 }
1.60
1.61 + /// <summary>
1.62 + ///
1.63 + /// </summary>
1.64 + /// <param name="graphics"></param>
1.65 + /// <param name="pen"></param>
1.66 + /// <param name="fftBuffer"></param>
1.67 + /// <param name="size"></param>
1.68 private void CreateSpectrumLineInternal(Graphics graphics, Pen pen, float[] fftBuffer, Size size)
1.69 {
1.70 int height = size.Height;