public void BltToFront() { RenderLock.WaitLock(); try { GDIRender.BitBlt(backgroundRenderGraphic.GetHdc(), 0, 0, backgroundGraph.ClientRectangle.Width, backgroundGraph.ClientRectangle.Height, backgroundDrawGraphic.GetHdc(), 0, 0, 13369376); backgroundDrawGraphic.ReleaseHdc(); backgroundRenderGraphic.ReleaseHdc(); graphicsBuffer.Render(backgroundGraphic); } finally { RenderLock.Unlock(); } }
public void BltToFront(int srcX, int srcY, int dstX, int dstY, int Width, int Height) { RenderLock.WaitLock(); try { IntPtr hdc = backgroundDrawGraphic.GetHdc(); GDIRender.BitBlt(backgroundRenderGraphic.GetHdc(), dstX, dstY, Width, Height, hdc, srcX, srcY, 13369376); backgroundDrawGraphic.ReleaseHdc(); backgroundRenderGraphic.ReleaseHdc(); graphicsBuffer.Render(backgroundGraphic); } finally { RenderLock.Unlock(); } }
public void Dispose() { if (backgroundGraphic != null) { backgroundGraphic.Dispose(); } backgroundGraphic = null; if (graphicsBuffer != null) { graphicsBuffer.Dispose(); } graphicsBuffer = null; if (backgroundRenderGraphic != null) { backgroundRenderGraphic.Dispose(); } backgroundRenderGraphic = null; if (backgroundMemoryBitmap != null) { GDIRender.DeleteObject(memoryBitmapHdc); backgroundMemoryBitmap.Dispose(); } backgroundMemoryBitmap = null; if (backgroundMemoryGraphic != null) { GDIRender.DeleteObject(memoryGraphicHdc); backgroundMemoryGraphic.Dispose(); } backgroundMemoryGraphic = null; if (backgroundDrawGraphic != null) { backgroundDrawGraphic.Dispose(); } backgroundDrawGraphic = null; }
public int ResetDraw(Panel GraphOle, Color BackColor) { if (GraphOle == null || GraphOle.GetType() != typeof(Panel) || GraphOle.ClientRectangle.Width < 1 || GraphOle.ClientRectangle.Height < 1) { return(-1); } RenderLock.WaitLock(); backgroundGraph = GraphOle; lock (backgroundGraph) { if (backgroundGraphic != null) { backgroundGraphic.Dispose(); } if (graphicsBuffer != null) { graphicsBuffer.Dispose(); } if (backgroundRenderGraphic != null) { backgroundRenderGraphic.Dispose(); } if (backgroundMemoryBitmap != null) { GDIRender.DeleteObject(memoryBitmapHdc); backgroundMemoryBitmap.Dispose(); } if (backgroundMemoryGraphic != null) { GDIRender.DeleteObject(memoryGraphicHdc); backgroundMemoryGraphic.Dispose(); } if (backgroundDrawGraphic != null) { backgroundDrawGraphic.Dispose(); } backgroundGraphic = backgroundGraph.CreateGraphics(); graphicsBuffer = BufferedGraphicsManager.Current.Allocate(backgroundGraphic, backgroundGraph.ClientRectangle); backgroundRenderGraphic = graphicsBuffer.Graphics; backgroundRenderGraphic.Clear(BackColor); backgroundRenderGraphic.SetClip(backgroundGraph.ClientRectangle); backgroundMemoryBitmap = new Bitmap(backgroundGraph.ClientRectangle.Width, backgroundGraph.ClientRectangle.Height, backgroundRenderGraphic); backgroundMemoryGraphic = Graphics.FromImage(backgroundMemoryBitmap); backgroundMemoryGraphic.Clear(BackColor); memoryGraphicHdc = GDIRender.CreateCompatibleDC(backgroundMemoryGraphic.GetHdc()); memoryBitmapHdc = backgroundMemoryBitmap.GetHbitmap(); GDIRender.SelectObject(memoryGraphicHdc, memoryBitmapHdc); backgroundDrawGraphic = Graphics.FromHdc(memoryGraphicHdc); switch (DrawQuality) { case DRAW_QUALITY.QUALITY_SUPER_HIGH: backgroundDrawGraphic.SmoothingMode = SmoothingMode.HighQuality; backgroundDrawGraphic.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; backgroundDrawGraphic.InterpolationMode = InterpolationMode.HighQualityBilinear; backgroundDrawGraphic.PixelOffsetMode = PixelOffsetMode.HighQuality; break; case DRAW_QUALITY.QUALITY_HIGH: backgroundDrawGraphic.SmoothingMode = SmoothingMode.AntiAlias; backgroundDrawGraphic.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; backgroundDrawGraphic.InterpolationMode = InterpolationMode.Bilinear; backgroundDrawGraphic.PixelOffsetMode = PixelOffsetMode.Half; break; case DRAW_QUALITY.QUALITY_MIDDLE: backgroundDrawGraphic.SmoothingMode = SmoothingMode.HighSpeed; backgroundDrawGraphic.TextRenderingHint = TextRenderingHint.AntiAlias; backgroundDrawGraphic.InterpolationMode = InterpolationMode.NearestNeighbor; backgroundDrawGraphic.PixelOffsetMode = PixelOffsetMode.HighSpeed; break; case DRAW_QUALITY.QUALITY_LOW: backgroundDrawGraphic.SmoothingMode = SmoothingMode.None; backgroundDrawGraphic.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit; backgroundDrawGraphic.InterpolationMode = InterpolationMode.Low; backgroundDrawGraphic.PixelOffsetMode = PixelOffsetMode.None; break; } } RenderLock.Unlock(); return(0); }