private void chopUpSingleUncompressedStrip()
{
uint bytecount = m_dir.td_stripbytecount[0];
uint offset = m_dir.td_stripoffset[0];
// Make the rows hold at least one scanline, but fill specified
// amount of data if possible.
int rowbytes = VTileSize(1);
uint stripbytes;
int rowsperstrip;
if (rowbytes > STRIP_SIZE_DEFAULT)
{
stripbytes = (uint)rowbytes;
rowsperstrip = 1;
}
else if (rowbytes > 0)
{
rowsperstrip = STRIP_SIZE_DEFAULT / rowbytes;
stripbytes = (uint)(rowbytes * rowsperstrip);
}
else
{
return;
}
// never increase the number of strips in an image
if (rowsperstrip >= m_dir.td_rowsperstrip)
return;
uint nstrips = howMany(bytecount, stripbytes);
if (nstrips == 0)
{
// something is wonky, do nothing.
return;
}
uint[] newcounts = new uint [nstrips];
uint[] newoffsets = new uint [nstrips];
// Fill the strip information arrays with new bytecounts and offsets
// that reflect the broken-up format.
for (int strip = 0; strip < nstrips; strip++)
{
if (stripbytes > bytecount)
stripbytes = bytecount;
newcounts[strip] = stripbytes;
newoffsets[strip] = offset;
offset += stripbytes;
bytecount -= stripbytes;
}
// Replace old single strip info with multi-strip info.
m_dir.td_nstrips = (int)nstrips;
m_dir.td_stripsperimage = (int)nstrips;
SetField(TiffTag.ROWSPERSTRIP, rowsperstrip);
m_dir.td_stripbytecount = newcounts;
m_dir.td_stripoffset = newoffsets;
m_dir.td_stripbytecountsorted = true;
}