Ejemplo n.º 1
0
        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();
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void DisposeSession()
 {
     if (_session != null)
     {
         _session.Dispose();
         _session = null;
     }
 }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
 //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;
 }
Ejemplo n.º 6
0
 internal void dispose()
 {
     graphics.Dispose();
     disposed = true;
 }
 /// <summary>
 /// Called when drawing has completed.
 /// </summary>
 public void EndDraw()
 {
     _canvas2d.Invalidate();
     _session.Dispose();
 }
Ejemplo n.º 8
0
 public void Dispose()
 {
     m_DSession.Dispose();
 }