예제 #1
0
 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
        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);
        }