Пример #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();
                    }
                }
            }
        }
Пример #2
0
 public void DisposeSession()
 {
     if (_session != null)
     {
         _session.Dispose();
         _session = null;
     }
 }
Пример #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);
        }
Пример #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);
            }
        }
Пример #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;
 }
Пример #6
0
 internal void dispose()
 {
     graphics.Dispose();
     disposed = true;
 }
 /// <summary>
 /// Called when drawing has completed.
 /// </summary>
 public void EndDraw()
 {
     _canvas2d.Invalidate();
     _session.Dispose();
 }
Пример #8
0
 public void Dispose()
 {
     m_DSession.Dispose();
 }