/// <summary> /// Creates a new filename and saves the content from the current BitmapGetter to the /// file format. This relies on the DataManager and will only be successful for /// formats supported by the write format possibility. This will not update this raster /// </summary> /// <param name="fileName">The string fileName to write to</param> /// <param name="progressHandler">The progress handler for creating a new bitmap.</param> /// <param name="bandType">The band type ot use.</param> public void ExportBitmap(string fileName, IProgressHandler progressHandler, ImageBandType bandType) { int rows = DataSet.NumRowsInFile; int cols = DataSet.NumColumnsInFile; IImageData result = DataManager.DefaultDataManager.CreateImage(fileName, rows, cols, false, progressHandler, bandType); int numBlocks = 1; if (rows * cols > 8000 * 8000) { numBlocks = Convert.ToInt32(Math.Ceiling(8000 * 8000 / (double)cols)); } int blockRows = (8000 * 8000) / cols; ProjectionHelper ph = new ProjectionHelper(DataSet.Extent, new Rectangle(0, 0, cols, rows)); for (int iblock = 0; iblock < numBlocks; iblock++) { int rowCount = blockRows; if (iblock == numBlocks - 1) { rowCount = rows - blockRows * iblock; } Rectangle r = new Rectangle(0, iblock * blockRows, cols, rowCount); Bitmap block = BitmapGetter.GetBitmap(ph.PixelToProj(r), r); result.WriteBlock(block, 0, iblock * blockRows); } }
/// <summary> /// This draws to the back buffer. If the back buffer doesn't exist, this will create one. /// This will not flip the back buffer to the front. /// </summary> /// <param name="args"></param> /// <param name="regions"></param> /// <param name="clipRectangles"></param> private void DrawWindows(MapArgs args, IList <Extent> regions, IList <Rectangle> clipRectangles) { Graphics g; if (args.Device != null) { g = args.Device; // A device on the MapArgs is optional, but overrides the normal buffering behaviors. } else { if (_backBuffer == null) { _backBuffer = new Bitmap(_bufferRectangle.Width, _bufferRectangle.Height); } g = Graphics.FromImage(_backBuffer); } int numBounds = Math.Min(regions.Count, clipRectangles.Count); for (int i = 0; i < numBounds; i++) { using (Bitmap bmp = BitmapGetter.GetBitmap(regions[i], clipRectangles[i])) { if (bmp != null) { g.DrawImage(bmp, clipRectangles[i]); } } } if (args.Device == null) { g.Dispose(); } }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing) { if (BitmapGetter != null) { BitmapGetter.Dispose(); BitmapGetter = null; } RasterLayerActions = null; Symbolizer = null; } base.Dispose(disposing); }