static bool writeBufferToSeparateStrips(Tiff outImage, byte[] buf, int imagelength, int imagewidth, short spp) { byte[] obuf = new byte[outImage.StripSize()]; FieldValue[] result = outImage.GetFieldDefaulted(TiffTag.ROWSPERSTRIP); int rowsperstrip = result[0].ToInt(); int rowsize = imagewidth * spp; int strip = 0; for (short s = 0; s < spp; s++) { for (int row = 0; row < imagelength; row += rowsperstrip) { int nrows = (row + rowsperstrip > imagelength) ? imagelength - row : rowsperstrip; int stripsize = outImage.VStripSize(nrows); cpContigBufToSeparateBuf(obuf, buf, row * rowsize + s, nrows, imagewidth, 0, 0, spp, 1); if (outImage.WriteEncodedStrip(strip++, obuf, stripsize) < 0) { Tiff.Error(outImage.FileName(), "Error, can't write strip {0}", strip - 1); return false; } } } return true; }
/* * Strip -> strip for change in encoding. */ bool cpDecodedStrips(Tiff inImage, Tiff outImage, int imagelength, int imagewidth, short spp) { int stripsize = inImage.StripSize(); byte[] buf = new byte[stripsize]; int ns = inImage.NumberOfStrips(); int row = 0; for (int s = 0; s < ns; s++) { int cc = (row + m_rowsperstrip > imagelength) ? inImage.VStripSize(imagelength - row) : stripsize; if (inImage.ReadEncodedStrip(s, buf, 0, cc) < 0 && !m_ignore) { Tiff.Error(inImage.FileName(), "Error, can't read strip {0}", s); return false; } if (outImage.WriteEncodedStrip(s, buf, cc) < 0) { Tiff.Error(outImage.FileName(), "Error, can't write strip {0}", s); return false; } row += m_rowsperstrip; } return true; }
static bool writeBufferToContigStrips(Tiff outImage, byte[] buffer, int imagelength, int imagewidth, short spp) { FieldValue[] result = outImage.GetFieldDefaulted(TiffTag.ROWSPERSTRIP); int rowsperstrip = result[0].ToInt(); int strip = 0; int offset = 0; for (int row = 0; row < imagelength; row += rowsperstrip) { int nrows = (row + rowsperstrip > imagelength) ? imagelength - row : rowsperstrip; int stripsize = outImage.VStripSize(nrows); if (outImage.WriteEncodedStrip(strip++, buffer, offset, stripsize) < 0) { Tiff.Error(outImage.FileName(), "Error, can't write strip {0}", strip - 1); return false; } offset += stripsize; } return true; }