/// <summary> /// AfterRender - Dispose of Graphics object created for rendering. /// </summary> private void RendererAfterRender() { if (graphics != null) { // Check if we only invalidated a rect if (invalidRect != SvgRectF.Empty) { // We actually drew everything on invalidatedRasterImage and now we // need to copy that to rasterImage Graphics tempGraphics = Graphics.FromImage(rasterImage); tempGraphics.DrawImage(invalidatedRasterImage, invalidRect.X, invalidRect.Y, GdiConverter.ToRectangle(invalidRect), GraphicsUnit.Pixel); tempGraphics.Dispose(); tempGraphics = null; // If we currently have an idMapRaster here, then we need to create // a temporary graphics object to draw the invalidated portion from // our main graphics window onto it. if (idMapRaster != null) { tempGraphics = Graphics.FromImage(idMapRaster); tempGraphics.DrawImage(graphics.IdMapRaster, invalidRect.X, invalidRect.Y, GdiConverter.ToRectangle(invalidRect), GraphicsUnit.Pixel); tempGraphics.Dispose(); tempGraphics = null; } else { idMapRaster = graphics.IdMapRaster; } // We have updated the invalid region invalidRect = SvgRectF.Empty; } else { if (idMapRaster != null && idMapRaster != graphics.IdMapRaster) { idMapRaster.Dispose(); } idMapRaster = graphics.IdMapRaster; } graphics.Dispose(); graphics = null; } }