コード例 #1
0
ファイル: Element.cs プロジェクト: Jchuchla/vixen-sall-vixen
 protected void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (CachedElementCanvas != null)
         {
             CachedElementCanvas.Dispose();
             CachedElementCanvas = null;
         }
     }
 }
コード例 #2
0
ファイル: Element.cs プロジェクト: ctmal/vixen
 public Bitmap Draw(Size imageSize, bool useCachedImage)
 {
     if ((CachedElementCanvas == null || !IsCanvasContentCurrent(imageSize) || CachedElementCanvas.Width != imageSize.Width || CachedElementCanvas.Height != imageSize.Height))
     {
         if (CachedElementCanvas != null)
         {
             CachedElementCanvas.Dispose();
         }
         CachedElementCanvas = SetupCanvas(imageSize);
         if (!useCachedImage || m_redraw)
         {
             using (Graphics g = Graphics.FromImage(CachedElementCanvas))
             {
                 DrawCanvasContent(g);
                 AddSelectionOverlayToCanvas(g);
                 m_rendered = true;
             }
             CachedCanvasIsCurrent = true;
             m_redraw = false;
         }
         else
         {
             using (Graphics g = Graphics.FromImage(CachedElementCanvas))
             {
                 AddSelectionOverlayToCanvas(g);
             }
         }
     }
     else
     {
         if (!useCachedImage && !m_rendered)
         {
             if (CachedElementCanvas != null)
             {
                 CachedElementCanvas.Dispose();
             }
             CachedElementCanvas = SetupCanvas(imageSize);
             using (Graphics g = Graphics.FromImage(CachedElementCanvas))
             {
                 DrawCanvasContent(g);
                 AddSelectionOverlayToCanvas(g);
                 m_rendered = true;
             }
         }
     }
     return(CachedElementCanvas);
 }
コード例 #3
0
ファイル: Element.cs プロジェクト: Jchuchla/vixen-sall-vixen
        public Bitmap SetupCachedImage(Size imageSize)
        {
            CachedCanvasIsCurrent = false;
            EffectNode.Effect.Render();             //ensure the effect is rendered outside of the locking.
            lock (drawLock) {
                Bitmap bitmap = new Bitmap(imageSize.Width, imageSize.Height);
                using (Graphics g = Graphics.FromImage(bitmap)){
                    DrawCanvasContent(g);
                    AddSelectionOverlayToCanvas(g, false);
                    if (CachedElementCanvas != null)
                    {
                        CachedElementCanvas.Dispose();
                    }

                    CachedElementCanvas   = bitmap;
                    Changed               = false;
                    CachedCanvasIsCurrent = true;
                }
            }

            return(CachedElementCanvas);
        }