Ejemplo n.º 1
0
 /// <summary>
 ///  Returns the data from the file in the form of ARGB bytes, regardless of how the image
 ///  data is actually stored in the file.
 /// </summary>
 /// <param name="startRow">The zero based integer index of the first row (Y)</param>
 /// <param name="startColumn">The zero based integer index of the first column (X)</param>
 /// <param name="numRows">The number of rows to read</param>
 /// <param name="numColumns">The number of columns to read</param>
 /// <param name="overview">The integer overview.  0 for the original image.  Each successive index divides the length and height in half.  </param>
 /// <returns>A Byte of values in ARGB order and in row-major raster-scan sequence</returns>
 public byte[] ReadWindow(int startRow, int startColumn, int numRows, int numColumns, int overview)
 {
     EnsureDatasetOpen();
     _red = _dataset.GetRasterBand(1);
     byte[] result = null;
     if (_red.GetRasterColorInterpretation() == ColorInterp.GCI_PaletteIndex)
     {
         result = ReadPaletteBuffered(startRow, startColumn, numRows, numColumns, overview);
     }
     if (_red.GetRasterColorInterpretation() == ColorInterp.GCI_GrayIndex)
     {
         result = ReadGrayIndex(startRow, startColumn, numRows, numColumns, overview);
     }
     if (_red.GetRasterColorInterpretation() == ColorInterp.GCI_RedBand)
     {
         result = ReadRgb(startRow, startColumn, numRows, numColumns, overview);
     }
     if (_red.GetRasterColorInterpretation() == ColorInterp.GCI_AlphaBand)
     {
         result = ReadArgb(startRow, startColumn, numRows, numColumns, overview);
     }
     return result;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Attempts to open the specified file.
        /// </summary>
        public override void Open()
        {
            try
            {
                _dataset = Gdal.Open(Filename, Access.GA_Update);
            }
            catch
            {
                try
                {
                    _dataset = Gdal.Open(Filename, Access.GA_ReadOnly);
                }
                catch (Exception ex)
                {
                    throw new GdalException(ex.ToString());
                }
            }

            _red = _dataset.GetRasterBand(1);
            if (_red.GetRasterColorInterpretation() == ColorInterp.GCI_PaletteIndex)
            {
                ReadPaletteBuffered();
            }
            if (_red.GetRasterColorInterpretation() == ColorInterp.GCI_GrayIndex)
            {
                ReadGrayIndex();
            }
            if (_red.GetRasterColorInterpretation() == ColorInterp.GCI_RedBand)
            {
                ReadRGB();
            }
            if (_red.GetRasterColorInterpretation() == ColorInterp.GCI_AlphaBand)
            {
                ReadARGB();
            }


        }
Ejemplo n.º 3
0
 /// <summary>
 /// Attempts to open the specified file.
 /// </summary>
 public override void Open()
 {
     _dataset = Helpers.Open(Filename);
     _red = _dataset.GetRasterBand(1);
     if (_red.GetRasterColorInterpretation() == ColorInterp.GCI_PaletteIndex)
     {
         ReadPaletteBuffered();
     }
     if (_red.GetRasterColorInterpretation() == ColorInterp.GCI_GrayIndex)
     {
         ReadGrayIndex();
     }
     if (_red.GetRasterColorInterpretation() == ColorInterp.GCI_RedBand)
     {
         ReadRgb();
     }
     if (_red.GetRasterColorInterpretation() == ColorInterp.GCI_AlphaBand)
     {
         ReadArgb();
     }
 }