private void UpdateImageSource(Rect updateRectangle) { if (Window.Current.Visible) { var imageRectangle = new Rect(new Point(), _canvasImageSource.Size); updateRectangle.Intersect(imageRectangle); if (updateRectangle.IsEmpty) { updateRectangle = imageRectangle; } CanvasDrawingSession drawingSession = null; try { drawingSession = _canvasImageSource.CreateDrawingSession(Colors.Transparent, updateRectangle); } catch { drawingSession = _canvasImageSource.CreateDrawingSession(Colors.Transparent, imageRectangle); } finally { if (drawingSession != null) { drawingSession.DrawImage(_accumulationRenderTarget); // Render target has the composed frame drawingSession.Dispose(); } } } }
public void DisposeSession() { if (_session != null) { _session.Dispose(); _session = null; } }
/// <summary> /// Called before drawing has started. /// </summary> public void BeginDraw() { if (_size_changed) { CanvasDevice device = CanvasDevice.GetSharedDevice(); _bitmap = new CanvasRenderTarget(device, _size.Width, _size.Height, 96); _size_changed = false; } if (_session != null) { _session.Dispose(); } _session = _bitmap.CreateDrawingSession(); _session.Clear(Colors.Transparent); }
void DrawToImageSource(CanvasDrawingSession canvasControlDrawingSession) { // XAML doesn't support nested image source drawing sessions, so we must close // the main CanvasControl one before drawing to a different CanvasImageSource. canvasControlDrawingSession.Dispose(); using (var ds = imageSource.CreateDrawingSession(Colors.Transparent)) { DrawToOutput(mainDeviceResources, ds); } }
//CanvasDrawingSession ls; public override void Invalidate(bool init = false) { if (init) { source.SetPixelBytes(b.PixelBuffer); } else { session.Dispose(); source.GetPixelBytes(b.PixelBuffer); b.Invalidate(); } session = source.CreateDrawingSession(); //session.Blend = Blend; }
internal void dispose() { graphics.Dispose(); disposed = true; }
/// <summary> /// Called when drawing has completed. /// </summary> public void EndDraw() { _canvas2d.Invalidate(); _session.Dispose(); }
public void Dispose() { m_DSession.Dispose(); }