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