/*
* Separate -> contig by row.
*/
bool cpSeparate2ContigByRow(Tiff inImage, Tiff outImage, int imagelength, int imagewidth, short spp)
{
byte[] inbuf = new byte[inImage.ScanlineSize()];
byte[] outbuf = new byte[outImage.ScanlineSize()];
for (int row = 0; row < imagelength; row++)
{
/* merge channels */
for (short s = 0; s < spp; s++)
{
if (!inImage.ReadScanline(inbuf, row, s) && !m_ignore)
{
Tiff.Error(inImage.FileName(), "Error, can't read scanline {0}", row);
return false;
}
int inp = 0;
int outp = s;
for (int n = imagewidth; n-- > 0; )
{
outbuf[outp] = inbuf[inp];
inp++;
outp += spp;
}
}
if (!outImage.WriteScanline(outbuf, row, 0))
{
Tiff.Error(outImage.FileName(), "Error, can't write scanline {0}", row);
return false;
}
}
return true;
}