protected void prepareReading() { isPrepared = false; System.IO.Stream stream = reader.BaseStream; try { getImageSize(0, out width, out height); nbits = getNumBits(0); pmi = getPhotometricInterpretation(0); getStrips(0, out stripPos, out stripCount, out rowCount); compid = getCompressionTagNumber(0); planarConfig = getPlanarConfiguration(0); diffTag = getDifferencePredictor(0); isFloat = isDataFloatPoint(0); } catch (ReadFileException ex) { throw ex; } catch (Exception ex) { throw new ReadFileException("Unabled to read TIF parameters", ex); } if (width <= 0 || height <= 0 || stripCount.Length != stripPos.Length || stripPos.Length == 0) { throw new ReadFileException("Invalid image info."); } if (nbits != 8 && nbits != 16 && nbits != 32) { throw new ReadFileException("Can only read 8/16/32 bit images."); } if (pmi != 0 && pmi != 1 && pmi != 2 && pmi != 3) { throw new ReadFileException("Not a valid TIFF image."); } if (nbits == 16) { totBytes = Convert.ToUInt32(width * height * 2); } else if (nbits == 32) { totBytes = Convert.ToUInt32(width * height * 4); } else { totBytes = Convert.ToUInt32(width * height); } spaceStrip = stripPos[stripPos.Length - 1] + stripCount[stripPos.Length - 1] - stripPos[0]; isPrepared = true; }
public StkWriter() : base() { CompressMethod = MyTiffCompression.CompressionMethod.UNCOMPRESSED; HorizontalDifferencing = false; }