public void WritePixels()
        {
            Erdas74Pixel8 pixel = new Erdas74Pixel8();
            
            WritableImage image = new WritableImage(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();
            
        }
Example #2
0
        private bool disposed = false; // track whether resources have been released

        /// <summary>
        /// Constructor - takes an already constructed ERDAS image file
        /// </summary>
        public OutputRaster(WritableImage image)
        {
            this.image = image;

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

            // Begin test bandtype compatibilities

            T desiredLayout = new T();

            int bandCount = desiredLayout.BandCount;

            System.TypeCode bandType = desiredLayout[0].TypeCode;

            // check band 0
            if (bandType != image.BandType)
            {
                throw new System.ApplicationException("OutputRaster band type mismatch");
            }

            // check bands 1 to n-1
            for (int i = 1; i < bandCount; i++)
            {
                IPixelBand band = desiredLayout[i];

                if (band.TypeCode != bandType)
                {
                    throw new System.ApplicationException("OutputRasters with mixed band types not supported");
                }
            }
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        public IOutputRaster <T> Create <T>(string path,
                                            Dimensions dimensions,
                                            IMetadata metadata)
            where T : IPixel, new()
        {
            // extract necessary parameters from pixel for image creation
            T desiredLayout = new T();

            int bandCount = desiredLayout.BandCount;

            System.TypeCode bandType = desiredLayout[0].TypeCode;

            // open image file for writing
            WritableImage image
                = new
                  WritableImage(path, dimensions, bandCount, bandType, metadata);

            // construct an OutputRaster from that
            return(new OutputRaster <T>(image));
        }
     public void WriteTooManyPixels()
     {
         WritableImage image = null;
         try {
             Erdas74Pixel8 pixel = new Erdas74Pixel8();
             
             image = new WritableImage(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();
         }
         
     }