public void ReadTooManyPixels()
     {
         ReadableImage image = null;
         try {
             image = new ReadableImage(inputLanImagePath);
             
             FredLanPixel pixel = new FredLanPixel();
 
             int pixCount = image.Dimensions.Rows * image.Dimensions.Columns;
             
             for (int i = 0; i < pixCount; i++)
             {
                 image.ReadPixel(pixel);
             }
         
             // one too many
             image.ReadPixel(pixel);
         }
         catch (System.Exception exc) {
             Data.Output.WriteLine(exc.Message);
             throw;
         }
         finally {
             if (image != null)
                 image.Close();
         }
     }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        public IInputRaster <T> Open <T>(string path)
            where T : IPixel, new()
        {
            // open image file for reading
            ReadableImage image = new ReadableImage(path);

            // construct an InputRaster using that
            return(new InputRaster <T>(image));
        }
 public void ReadPixels()
 {
     ReadableImage image = new ReadableImage(inputLanImagePath);
     
     FredLanPixel pixel = new FredLanPixel();
     
     int pixCount = image.Dimensions.Rows * image.Dimensions.Columns;
     
     for (int i = 0; i < pixCount; i++)
     {
         image.ReadPixel(pixel);
     }
     
     image.Close();
 }
Пример #4
0
        private T pixel;             // a pixel: used for xfering data

        /// <summary>
        /// Constructor - takes an already constructed ERDAS image file
        /// </summary>
        public InputRaster(ReadableImage image)
        {
            this.disposed = false;
            this.image    = image;
            this.pixel    = new T();

            // make sure we've got valid input
            if (this.image == null)
            {
                throw new System.ApplicationException("InputRaster constructor passed null image");
            }

            // pixel vs. image bandcount mismatch?
            int pixelBandCount = this.pixel.BandCount;

            if (pixelBandCount != image.BandCount)
            {
                throw new System.ApplicationException("InputRaster band count mismatch");
            }

            // check bandtype compatibilities
            for (int i = 0; i < pixelBandCount; i++)
            {
                IPixelBand band = this.pixel[i];

                if (image.BandType == System.TypeCode.Byte)
                {
                    if (band.TypeCode != System.TypeCode.Byte)
                    {
                        throw new System.ApplicationException("InputRaster band type mismatch");
                    }
                }
                else if (image.BandType == System.TypeCode.UInt16)
                {
                    if (band.TypeCode != System.TypeCode.UInt16)
                    {
                        throw new System.ApplicationException("InputRaster band type mismatch");
                    }
                }
                else
                {
                    throw new System.ApplicationException("InputRaster - Unsupported band type");
                }
                //  shouldn't really ever get to this exception
                //    ErdasImageFile construction code should have
                //    thrown an exception earlier
            }
        }