Kopieren Sie einen Teil der Zeichnung in derselben ZeichnungC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Kopieren Sie einen Teil der Zeichnung in derselben Zeichnung

Post by Anonymous »

Ich möchte einen "Wasserfall" fortsetzen, um ein Funkspektrum darzustellen. /> Ist das auch der richtige Ansatz in Win2D? Offscreen: < /p>

Code: Select all

private CanvasRenderTarget offscreen;
private CanvasDevice device = CanvasDevice.GetSharedDevice();
private DispatcherTimer Timer;
< /code>
Im Konstruktor: < /p>
offscreen = new CanvasRenderTarget(device, 300, 255, 96);
Timer = new DispatcherTimer();
Timer.Interval = TimeSpan.FromMilliseconds(refreshRate);
Timer.Tick += Timer_Tick;
Timer.Start();
< /code>
Arbeiten im Timer_tick -Ereignis: < /p>

private void Timer_Tick(object? sender, object e)
{
using (CanvasDrawingSession ds = offscreen.CreateDrawingSession())
{
// Draw rectangle
ds.FillRectangle(10, 10, 100, 100, Colors.Red);
// Source rect to be copied
Rect sourceRegion = new Rect(10, 10, 50, 50);
// Define the destination point on the current canvas
Vector2 destinationPoint = new Vector2(150, 150);
// Copy the specified region from the source to the destination
**ds.DrawImage(offscreen, destinationPoint, sourceRegion); // Unhandled error**
}
if (this.waterfallCanvas != null) this.waterfallCanvas.Invalidate();
}

private void waterfallCanvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
{
if (offscreen != null) args.DrawingSession.DrawImage(offscreen, 0, 0);
}
Es wirft eine unberechtigte Interopervices aus.>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post