Exemplo n.º 1
0
        public void updateCanvas(Graphics k)
        {
            if (ss.getBitmapLayerUpdate() != null)
            {
                lv.updateActiveLayer();
            }

            SharedSettings.bitmapCanvas = lv.getRender();
            Bitmap bit2 = (Bitmap)bg.Clone();

            Graphics temp = Graphics.FromImage(bit2);

            temp.DrawImage(SharedSettings.bitmapCanvas, 0, 0);

            Bitmap iitmp = ss.getImportImage();

            if (iitmp != null)
            {
                lv.addImportImage(iitmp);
            }

            p.Invalidate();

            //if (GCCurrentFrame == GCperFrames)
            //{
            //    System.GC.Collect(); //Prevent OutOfMemory Execptions
            //}
            //GCCurrentFrame += 1;
            //GCCurrentFrame %= 100;

            System.GC.Collect();

            p.Width  = (int)(ss.getDrawScale() * ss.getCanvasWidth());
            p.Height = (int)(ss.getDrawScale() * ss.getCanvasHeight());
            Rectangle source = new Rectangle(0, 0, bit2.Width, bit2.Height);
            Rectangle dest   = new Rectangle(0, 0, p.Width, p.Height);

            k.InterpolationMode = InterpolationMode.NearestNeighbor;
            k.PixelOffsetMode   = PixelOffsetMode.Half;

            if (ss.getRenderBitmapInterface() && ss.getInterfaceBitmap() != null)
            {
                Tools[6].updateInterfaceLayer();
                temp.DrawImage(ss.getInterfaceBitmap(), 0, 0);
            }

            if (ss.getActiveSelection() && ss.getBitmapSelectionArea() != null)
            {
                temp.DrawImage(ss.getBitmapSelectionArea(), ss.getSelectionPoint().X, ss.getSelectionPoint().Y);
            }

            if (ss.getFlattenSelection())
            {
                ss.setFlattenSelection(false);
                lv.updateActiveLayerSettings();
                foreach (ITool t in Tools)
                {
                    if (t is SelectionTool)
                    {
                        ((SelectionTool)t).Clean();
                    }
                }
            }

            handleWatermark(temp);

            k.DrawImage(bit2, dest, source, GraphicsUnit.Pixel);
            if (ss.getGridToggle())
            {
                lv.GridDraw(k);
            }

            bit2.Dispose();
            if (iitmp != null)
            {
                iitmp.Dispose();
            }
        }