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;
}