Exemplo n.º 1
0
        /// <summary>
        /// Create an Erdas image file given specs
        /// </summary>
        public Image(string filename,
                     Dimensions dimensions,
                     int bandCount,
                     System.TypeCode bandType,
                     IMetadata metadata)
        {
            // if filename does not end in .gis or .lan throw exception
            string extension = Path.GetExtension(filename).ToLower();
            if (!(extension.Equals(".gis")) && !(extension.Equals(".lan")))
                throw new ApplicationException("Erdas image must have either GIS or LAN as extension");
                
            // if dimensions are messed up throw exception
            if ((dimensions.Rows < 1) || (dimensions.Columns < 1))
                throw new ApplicationException("Erdas image given invalid dimensions");
                
            // if bandCount messed up throw exception
            if ((bandCount < 1) || (bandCount > 0xffff))
                throw new ApplicationException("Erdas image given invalid band count");
            
            // more bandCount checking
            if (extension.Equals(".gis"))
            {
                if (bandCount > 1)
                    throw new ApplicationException("Erdas GIS files cannot support multiband images");
            }
                
            this.imageHeader =
                new ImageHeader(dimensions, bandType, bandCount, metadata);

            this.imageHeader.Write(filename);            
        }
Exemplo n.º 2
0
        /// <summary>
        /// Open an existing Erdas image file
        /// </summary>
        public Image(string filename)
        {
            // if filename does not end in .gis or .lan throw exception
            string extension = Path.GetExtension(filename).ToLower();
            if (!(extension.Equals(".gis")) && !(extension.Equals(".lan")))
                throw new ApplicationException("Erdas file must have either GIS or LAN as extension");
                
            this.imageHeader = new ImageHeader();

            this.imageHeader.Read(filename);
        }