Answer the question
In order to leave comments, you need to log in
Why might there be a problem with asynchrony in this place?
Here is a code snippet:
private static Image Render(IPeakProvider peakProvider, WaveFormRendererSettings settings)
{
if (settings.DecibelScale)
peakProvider = new DecibelPeakProvider(peakProvider, 48);
var b = new Bitmap(settings.Width, settings.TopHeight + settings.BottomHeight);
if (settings.BackgroundColor == Color.Transparent)
{
b.MakeTransparent();
}
using (var g = Graphics.FromImage(b))
{
g.FillRectangle(settings.BackgroundBrush, 0,0,b.Width,b.Height);
var midPoint = settings.TopHeight;
int x = 0;
var currentPeak = peakProvider.GetNextPeak();
while (x < settings.Width)
{
var nextPeak = peakProvider.GetNextPeak();
for (int n = 0; n < settings.PixelsPerPeak; n++)
{
var lineHeight = settings.TopHeight * currentPeak.Max;
g.DrawLine(settings.TopPeakPen, x, midPoint, x, midPoint - lineHeight);
lineHeight = settings.BottomHeight * currentPeak.Min;
g.DrawLine(settings.BottomPeakPen, x, midPoint, x, midPoint - lineHeight);
x++;
}
....
...
var image = await Task.Run(() =>
{
return waveFormRenderer.Render(filePath, peakProvider, settings);
});
...
g.DrawLine(settings.TopPeakPen, x, midPoint, x, midPoint - lineHeight);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question