Beispiel #1
0
        public void ReadTooManyPixels()
        {
            ErdasImageFile image = null;

            try {
                image = new ErdasImageFile(inputLanImagePath, RWFlag.Read);

                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();
                }
            }
        }
Beispiel #2
0
        public void ReadFromWritable1()
        {
            ErdasImageFile image = null;

            try {
                image = new ErdasImageFile(Data.MakeOutputPath("junk.gis"),
                                           new Dimensions(10, 10),
                                           1,
                                           System.TypeCode.Byte,
                                           null);

                Erdas74Pixel8 pixel = new Erdas74Pixel8();

                // read after opening for Write
                image.ReadPixel(pixel);
            }
            catch (System.Exception exc) {
                Data.Output.WriteLine(exc.Message);
                throw;
            }
            finally {
                if (image != null)
                {
                    image.Close();
                }
            }
        }
Beispiel #3
0
        public void WritePixels()
        {
            Erdas74Pixel8 pixel = new Erdas74Pixel8();

            ErdasImageFile
                image = new ErdasImageFile(outputGisImagePath,
                                           new Dimensions(10, 10),
                                           1,
                                           System.TypeCode.Byte,
                                           null);

            byte[] bytes = new byte[1];
            bytes[0] = 1;

            pixel[0].SetBytes(bytes, 0);

            int pixCount = image.Dimensions.Rows * image.Dimensions.Columns;

            for (int i = 0; i < pixCount; i++)
            {
                image.WritePixel(pixel);
            }

            image.Close();
        }
Beispiel #4
0
        public void OpenExistingWritable()
        {
            ErdasImageFile
                image = new ErdasImageFile(outputGisImagePath, RWFlag.Write);

            image.Close();
        }
Beispiel #5
0
        public void OpenExistingReadOnly()
        {
            ErdasImageFile
                image = new ErdasImageFile(inputGisImagePath, RWFlag.Read);

            image.Close();
        }
Beispiel #6
0
        public void ReadPixels()
        {
            ErdasImageFile
                image = new ErdasImageFile(inputLanImagePath, RWFlag.Read);

            FredLanPixel pixel = new FredLanPixel();

            int pixCount = image.Dimensions.Rows * image.Dimensions.Columns;

            for (int i = 0; i < pixCount; i++)
            {
                image.ReadPixel(pixel);
            }

            image.Close();
        }
Beispiel #7
0
        public void ConstructNewGis()
        {
            ErdasImageFile
                image = new ErdasImageFile(outputGisImagePath,
                                           new Dimensions(60, 40),
                                           1,
                                           System.TypeCode.Byte,
                                           null);

            Assert.AreEqual(60, image.Dimensions.Rows);
            Assert.AreEqual(40, image.Dimensions.Columns);
            Assert.AreEqual(1, image.BandCount);
            Assert.AreEqual(System.TypeCode.Byte, image.BandType);
            Assert.AreEqual(null, image.Metadata);

            image.Close();  // needed or file stays locked after run of tests. why?
        }
Beispiel #8
0
        public void ConstructNewLan()
        {
            ErdasImageFile
                image =
                new ErdasImageFile(outputLanImagePath,
                                   new Dimensions(100, 50),
                                   2,
                                   System.TypeCode.UInt16,
                                   null);

            Assert.AreEqual(100, image.Dimensions.Rows);
            Assert.AreEqual(50, image.Dimensions.Columns);
            Assert.AreEqual(2, image.BandCount);
            Assert.AreEqual(System.TypeCode.UInt16, image.BandType);
            Assert.AreEqual(null, image.Metadata);

            image.Close();  // needed or file stays locked after run of tests. why?
        }
Beispiel #9
0
        public void Init()
        {
            gisImagePath = Data.MakeOutputPath("OutputRasterTests.gis");
            ErdasImageFile image;

            image = new ErdasImageFile(gisImagePath,
                                       new Dimensions(60, 40),
                                       1,
                                       System.TypeCode.Byte,
                                       null);
            image.Close();

            lanImagePath = Data.MakeOutputPath("OutputRasterTests.lan");
            image        = new ErdasImageFile(lanImagePath,
                                              new Dimensions(100, 50),
                                              2,
                                              System.TypeCode.UInt16,
                                              null);
            image.Close();
        }
Beispiel #10
0
        private void TryCtor <T>(string imagePath,
                                 RWFlag rwFlag)
            where T : IPixel, new()
        {
            ErdasImageFile image = null;

            try {
                image = new ErdasImageFile(imagePath, rwFlag);
                OutputRaster <T> raster = new OutputRaster <T>(image);
            }
            catch (System.Exception exc) {
                Data.Output.WriteLine(exc.Message);
                throw;
            }
            finally {
                if (image != null)
                {
                    image.Close();
                }
            }
        }
Beispiel #11
0
        public void WriteTooManyPixels()
        {
            ErdasImageFile image = null;

            try {
                Erdas74Pixel8 pixel = new Erdas74Pixel8();

                image = new ErdasImageFile(outputGisImagePath,
                                           new Dimensions(10, 10),
                                           1,
                                           System.TypeCode.Byte,
                                           null);

                byte[] bytes = new byte[1];
                bytes[0] = 1;

                pixel[0].SetBytes(bytes, 0);

                int pixCount = image.Dimensions.Rows * image.Dimensions.Columns;

                for (int i = 0; i < pixCount; i++)
                {
                    image.WritePixel(pixel);
                }

                // one too many
                image.WritePixel(pixel);
            }
            catch (System.Exception exc) {
                Data.Output.WriteLine(exc.Message);
                throw;
            }
            finally {
                if (image != null)
                {
                    image.Close();
                }
            }
        }
Beispiel #12
0
        public void WriteToReadable()
        {
            ErdasImageFile image = null;

            try {
                image = new ErdasImageFile(Data.MakeOutputPath("junk.gis"),
                                           RWFlag.Read);

                Erdas74Pixel8 pixel = new Erdas74Pixel8();

                // write after opening for Read
                image.WritePixel(pixel);
            }
            catch (System.Exception exc) {
                Data.Output.WriteLine(exc.Message);
                throw;
            }
            finally {
                if (image != null)
                {
                    image.Close();
                }
            }
        }