/// <summary> /// Read a pixel from the file. Assumes pixels will be read /// by the caller consecutively from upper left to bottom /// right a row at a time /// </summary> public void ReadPixel(IPixel pixel) { int bandCount = pixel.BandCount; for (int bandNum = 0; bandNum < bandCount; bandNum++) { IPixelBand band = pixel[bandNum]; // calc this pixelband's location in file int location = PixelBandLocation(pixelsRead, bandNum); // seek to correct pixel spot this.fileReader.BaseStream.Seek(location, SeekOrigin.Begin); byte[] bytes = this.fileReader.ReadBytes(this.BandSize); band.SetBytes(bytes, 0); } pixelsRead++; }
/// <summary> /// Read a pixel from the file. Assumes pixels will be read /// by the caller consecutively from upper left to bottom /// right a row at a time /// </summary> public void ReadPixel(IPixel pixel) { try { if ((fileReader == null) || (!this.open)) { throw new System.ApplicationException("Raster not open for reading"); } if (currPixel >= totalPixels) { throw new System.ApplicationException("Reading beyond end of pixel data"); } int bandCount = pixel.BandCount; for (int bandNum = 0; bandNum < bandCount; bandNum++) { IPixelBand band = pixel[bandNum]; // calc this pixelband's location in file int location = PixelBandLocation(currPixel, bandNum); // seek to correct pixel spot this.fileReader.BaseStream.Seek(location, SeekOrigin.Begin); byte[] bytes = this.fileReader.ReadBytes(bandSize); band.SetBytes(bytes, 0); } currPixel++; } catch (System.Exception) { Close(); throw; } }