public static void RenderSeperate(WaveFormRendererData rendererData, BitmapHelper.RenderInfo waveRenderInfo, BitmapHelper.RenderInfo powerRenderInfo, bool rms) { if (rms) { var waveElements = rendererData.WaveElements; var powerElements = rendererData.PowerElements; for (var position = 0; position < rendererData.Position; position++) { for (var channel = 0; channel < rendererData.Channels; channel++) { var waveElement = waveElements[position, channel]; var powerElement = powerElements[position, channel]; BitmapHelper.DrawRectangle( waveRenderInfo, position, waveElement.Y, 1, waveElement.Height ); BitmapHelper.DrawRectangle( powerRenderInfo, position, powerElement.Y, 1, powerElement.Height ); } } } else { var elements = rendererData.WaveElements; for (var position = 0; position < rendererData.Position; position++) { for (var channel = 0; channel < rendererData.Channels; channel++) { var element = elements[position, channel]; BitmapHelper.DrawRectangle( waveRenderInfo, position, element.Y, 1, element.Height ); } } } }
protected virtual async Task Render() { const byte SHADE = 30; var bitmap = default(WriteableBitmap); var success = default(bool); var valueRenderInfo = default(BitmapHelper.RenderInfo); var rmsRenderInfo = default(BitmapHelper.RenderInfo); await Windows.Invoke(() => { bitmap = this.Bitmap; success = bitmap.TryLock(LockTimeout); if (!success) { return; } if (this.ShowRms.Value) { var colors = this.Color.ToPair(SHADE); valueRenderInfo = BitmapHelper.CreateRenderInfo(bitmap, colors[0]); rmsRenderInfo = BitmapHelper.CreateRenderInfo(bitmap, colors[1]); } else { valueRenderInfo = BitmapHelper.CreateRenderInfo(bitmap, this.Color); } }).ConfigureAwait(false); if (!success) { //Failed to establish lock. this.Start(); return; } Render(valueRenderInfo, rmsRenderInfo, this.RendererData); await Windows.Invoke(() => { bitmap.AddDirtyRect(new Int32Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight)); bitmap.Unlock(); }).ConfigureAwait(false); this.Start(); }
public static void Render(WaveFormRendererData rendererData, BitmapHelper.RenderInfo waveRenderInfo, BitmapHelper.RenderInfo powerRenderInfo, bool rms, WaveFormRendererMode mode) { BitmapHelper.Clear(waveRenderInfo); switch (mode) { case WaveFormRendererMode.Mono: RenderMono(rendererData, waveRenderInfo, powerRenderInfo, rms); break; case WaveFormRendererMode.Seperate: RenderSeperate(rendererData, waveRenderInfo, powerRenderInfo, rms); break; default: throw new NotImplementedException(); } }
private static void RenderSeperate(BitmapHelper.RenderInfo info, Int32Point[,] elements, int channels, int width) { for (var channel = 0; channel < channels; channel++) { for (var x = 0; x < width - 1; x++) { var point1 = elements[channel, x]; var point2 = elements[channel, x + 1]; BitmapHelper.DrawLine( info, point1.X, point1.Y, point2.X, point2.Y ); } } }
private static void Render(BitmapHelper.RenderInfo info, OscilloscopeRendererData data) { BitmapHelper.Clear(info); if (data.Elements != null) { switch (data.Mode) { default: case OscilloscopeRendererMode.Mono: RenderMono(info, data.Elements, data.Width); break; case OscilloscopeRendererMode.Seperate: RenderSeperate(info, data.Elements, data.Channels, data.Width); break; } } }
private static void Render(BitmapHelper.RenderInfo valueRenderInfo, BitmapHelper.RenderInfo rmsRenderInfo, PeakRendererData rendererData) { var valueElements = rendererData.ValueElements; var rmsElements = rendererData.RmsElements; var peakElements = rendererData.PeakElements; var orientation = rendererData.Orientation; BitmapHelper.Clear(valueRenderInfo); if (valueElements != null) { for (var a = 0; a < valueElements.Length; a++) { BitmapHelper.DrawRectangle( valueRenderInfo, valueElements[a].X, valueElements[a].Y, valueElements[a].Width, valueElements[a].Height ); if (rmsElements != null) { if (rmsElements[a].Height > 0) { BitmapHelper.DrawRectangle( rmsRenderInfo, rmsElements[a].X, rmsElements[a].Y, rmsElements[a].Width, rmsElements[a].Height ); } } if (peakElements != null) { if (orientation == Orientation.Horizontal) { if (peakElements[a].X > valueElements[a].Width) { BitmapHelper.DrawRectangle( valueRenderInfo, peakElements[a].X, peakElements[a].Y, peakElements[a].Width, peakElements[a].Height ); } } else if (orientation == Orientation.Vertical) { if (peakElements[a].Y < valueElements[a].Y) { BitmapHelper.DrawRectangle( valueRenderInfo, peakElements[a].X, peakElements[a].Y, peakElements[a].Width, peakElements[a].Height ); } } } } } }
private static void Render(BitmapHelper.RenderInfo valueRenderInfo, BitmapHelper.RenderInfo rmsRenderInfo, BitmapHelper.RenderInfo crestRenderInfo, SpectrumRendererData rendererData) { var valueElements = rendererData.ValueElements; var rmsElements = rendererData.RmsElements; var crestPoints = rendererData.CrestPoints; var peakElements = rendererData.PeakElements; BitmapHelper.Clear(valueRenderInfo); for (var a = 0; a < valueElements.Length; a++) { BitmapHelper.DrawRectangle( valueRenderInfo, valueElements[a].X, valueElements[a].Y, valueElements[a].Width, valueElements[a].Height ); if (rmsElements != null) { if (rmsElements[a].Height > 0) { BitmapHelper.DrawRectangle( rmsRenderInfo, rmsElements[a].X, rmsElements[a].Y, rmsElements[a].Width, rmsElements[a].Height ); } } if (peakElements != null) { if (peakElements[a].Y < valueElements[a].Y) { BitmapHelper.DrawRectangle( valueRenderInfo, peakElements[a].X, peakElements[a].Y, peakElements[a].Width, peakElements[a].Height ); } } } if (crestPoints != null) { for (var a = 0; a < crestPoints.Length - 1; a++) { var point1 = crestPoints[a]; var point2 = crestPoints[a + 1]; BitmapHelper.DrawLine( crestRenderInfo, point1.X, point1.Y, point2.X, point2.Y ); } } }