Ejemplo n.º 1
0
 private void ReadHeader()
 {
     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());
         }
     }
     Init(_dataset.RasterXSize, _dataset.RasterYSize);
     NumBands = _dataset.RasterCount;
     WorldFile = new WorldFile();
     WorldFile.Affine = new double[6];
     double[] test = new double[6];
     _dataset.GetGeoTransform(test);
     Bounds = new RasterBounds(Height, Width, test);
     WorldFile.Affine = test;
     Close();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new instance of gdalImage
 /// </summary>
 public GdalTiledImage(string filename):base(filename)
 {
     WorldFile = new WorldFile();
     WorldFile.Affine = new double[6];
     Gdal.AllRegister();
     ReadHeader();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new instance of gdalImage, and gets much of the header information without actually
        /// reading any values from the file.
        /// </summary>
        public GdalImage(string filename)
        {
            Filename = filename;
            WorldFile = new WorldFile();
            WorldFile.Affine = new double[6];

            Gdal.AllRegister();
            ReadHeader();
            

        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates the bitmap from the raw image specified.  The bounds should be set on this later.
 /// </summary>
 /// <param name="rawImage">The raw image.</param>
 public MWImageData(Image rawImage)
 {
     _myImage = new Bitmap(rawImage.Width, rawImage.Height);
     Graphics g = Graphics.FromImage(_myImage);
     g.DrawImageUnscaled(rawImage, 0, 0);
     g.Dispose();
     WorldFile = new WorldFile();
     double[] aff = new[] { 1.0, 0, 0, -1.0, 0, _myImage.Height };
     Bounds = new RasterBounds(_myImage.Height, _myImage.Width, aff);
     MemorySetup();
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructs a new imagedata of the specified width and height.
 /// </summary>
 /// <param name="width"></param>
 /// <param name="height"></param>
 public MWImageData(int width, int height)
 {
     WorldFile = new WorldFile();
     double[] aff = new[] { 1.0, 0, 0, -1.0, 0, height };
     Bounds = new RasterBounds(height, width, aff);
     _myImage = new Bitmap(width, height);
     MemorySetup();
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Opens the file, assuming that the filename has already been specified using a Dot Net Image object
 /// </summary>
 public override void Open()
 {
     if (_myImage != null) _myImage.Dispose();
     Image temp;
     try
     {
         temp = Image.FromFile(Filename);
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show("The Dot Net Image object threw the following exception: " + ex.Message);
         return;
     }
     _myImage = new Bitmap(temp.Width, temp.Height, PixelFormat.Format32bppArgb);
     Graphics g = Graphics.FromImage(_myImage);
     g.DrawImage(temp, new Rectangle(0, 0, temp.Width, temp.Height));
     g.Dispose();
     temp.Dispose();
     WorldFile = new WorldFile(Filename);
     if (WorldFile.Affine == null)
     {
         WorldFile.Affine = new[] { .5, 1.0, 0, _myImage.Height - .5, 0, -1.0 };
     }
   
     Bounds = new RasterBounds(_myImage.Height, _myImage.Width, WorldFile.Affine);
     NumBands = 4;
     BytesPerPixel = 4;
     ReadBytes();
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Creates a new image and world file, placing the default bounds at the origin, with one pixel per unit.
 /// </summary>
 /// <param name="filename">The string filename</param>
 /// <param name="width">The integer width</param>
 /// <param name="height">The integer height</param>
 public override void CreateNew(string filename, int width, int height)
 {
     Filename = filename;
     WorldFile = new WorldFile();
     double[] aff = new[] { 1.0, 0, 0, -1.0, 0, height };
     Bounds = new RasterBounds(height, width, aff);
     WorldFile.Filename = WorldFile.GenerateFilename(filename);
     _myImage = new Bitmap(width, height);
     string ext = System.IO.Path.GetExtension(filename);
     switch (ext)
     {
         case ".bmp": _myImage.Save(filename, ImageFormat.Bmp); break;
         case ".emf": _myImage.Save(filename, ImageFormat.Emf); break;
         case ".exf": _myImage.Save(filename, ImageFormat.Exif); break;
         case ".gif": _myImage.Save(filename, ImageFormat.Gif); break;
         case ".ico": _myImage.Save(filename, ImageFormat.Icon); break;
         case ".jpg": _myImage.Save(filename, ImageFormat.Jpeg); break;
         case ".mbp": _myImage.Save(filename, ImageFormat.MemoryBmp); break;
         case ".png": _myImage.Save(filename, ImageFormat.Png); break;
         case ".tif": _myImage.Save(filename, ImageFormat.Tiff); break;
         case ".wmf": _myImage.Save(filename, ImageFormat.Wmf); break;
     }
     NumBands = 4;
     BytesPerPixel = 4;
     ReadBytes();
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a new instance of ImageData
 /// </summary>
 public ImageData()
 {
     TypeName = "Image";
     _bounds = new RasterBounds(0, 0, new double[] { 0, 1, 0, 0, 0, -1 });
     _worldFile = new WorldFile();
 }