|
@@ -166,6 +166,9 @@ namespace BeatLyrics.Tool.UserControls
|
|
|
|
|
|
var blockWidth = _spectrumBlockInMs * DisplayScale;
|
|
|
|
|
|
+ var rects = new List<Tuple<RectangleF, byte>>();
|
|
|
+
|
|
|
+
|
|
|
for (var i = beginBlockIndex; i < endBlockIndex; i++)
|
|
|
{
|
|
|
var posX = i * blockWidth;
|
|
@@ -175,11 +178,8 @@ namespace BeatLyrics.Tool.UserControls
|
|
|
var freqArray = block.FreqAxis.Where(p => p > MinSaFreq && p < MaxSaFreq).ToArray();
|
|
|
var height = scaleHeight / freqArray.Length;
|
|
|
|
|
|
- var rects = new Tuple<RectangleF, byte>[freqArray.Length];
|
|
|
- for (var index = 0; index < freqArray.Length; index++)
|
|
|
+ foreach (var freq in freqArray)
|
|
|
{
|
|
|
- var freq = freqArray[index];
|
|
|
-
|
|
|
var val = block.Values[Array.IndexOf(block.FreqAxis, freq)];
|
|
|
|
|
|
var posY = scaleHeight * (1 - (freq - MinSaFreq) / freqRange);
|
|
@@ -194,16 +194,14 @@ namespace BeatLyrics.Tool.UserControls
|
|
|
color = (byte)(255 * ratio);
|
|
|
}
|
|
|
|
|
|
- rects[index] = new Tuple<RectangleF, byte>(
|
|
|
- new RectangleF(posX, (float)posY, blockWidth, height), color
|
|
|
- );
|
|
|
+ rects.Add(new Tuple<RectangleF, byte>(new RectangleF(posX, (float)posY, blockWidth, height), color));
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- foreach (var item in rects.Where(p => p != null).GroupBy(p => p.Item2).Where(p => p.Key > 0))
|
|
|
- {
|
|
|
- using Brush brush = new SolidBrush(Color.FromArgb(255 - item.Key, 255 - item.Key, 255));
|
|
|
- e.Graphics.FillRectangles(brush, item.Select(p => p.Item1).ToArray());
|
|
|
- }
|
|
|
+ foreach (var item in rects.Where(p => p != null).GroupBy(p => p.Item2).Where(p => p.Key > 0))
|
|
|
+ {
|
|
|
+ using Brush brush = new SolidBrush(Color.FromArgb(255 - item.Key, 255 - item.Key, 255));
|
|
|
+ e.Graphics.FillRectangles(brush, item.Select(p => p.Item1).ToArray());
|
|
|
}
|
|
|
}
|
|
|
|