void getTifImageParameters(string _fileName) { switch (_type) { case Giwer.frmDataStock.fTypes.Tif: Bitmap bmpTif = (Bitmap)Bitmap.FromFile(_fileName); BitmapData bitmapdataTif = bmpTif.LockBits(new Rectangle(0, 0, bmpTif.Width, bmpTif.Height), ImageLockMode.ReadOnly, bmpTif.PixelFormat); _imageHeight = bmpTif.Height; _imageWidth = bmpTif.Width; _stride = bitmapdataTif.Stride; bmpTif.UnlockBits(bitmapdataTif); _nbands = 3; _bytesPerPixel = 3; bmpTif.Dispose(); return; case Giwer.frmDataStock.fTypes.Bil: ESRI_BIL bl = new ESRI_BIL(); bl.FileName = _fileName; _imageHeight = bl.Nrows; _imageWidth = bl.Ncols; _bytesPerPixel = bl.Nbits; _nbands = bl.Nbands; _stride = bl.Ncols * bl.Nbits; return; } }
public ImageData(string fName, Giwer.frmDataStock.fTypes ftype) { _fileName = fName; _type = ftype; if (_type == Giwer.frmDataStock.fTypes.Tif) { getTifImageParameters(_fileName); } if (_type == Giwer.frmDataStock.fTypes.Gwr) { getHdrParameters(fName); } if (_type == Giwer.frmDataStock.fTypes.Bil) { ESRI_BIL bl = new ESRI_BIL(); bl.FileName = fName; bl.parseHeader(); _fileName = fName; _type = ftype; _imageHeight = bl.Nrows; _imageWidth = bl.Ncols; _nbands = bl.Nbands; _bytesPerPixel = bl.Nbits; } }