private bool JPEGDecode(byte[] buffer, int offset, int count, short plane)
{
int nrows = count / m_bytesperline;
if ((count % m_bytesperline) != 0)
Tiff.WarningExt(m_tif, m_tif.m_clientdata, m_tif.m_name, "fractional scanline not read");
if (nrows > (int)m_decompression.Image_height)
nrows = m_decompression.Image_height;
// data is expected to be read in multiples of a scanline
if (nrows != 0)
{
byte[][] bufptr = new byte[1][];
bufptr[0] = new byte[m_bytesperline];
do
{
// In the 8bit case. We read directly into the TIFF buffer.
Array.Clear(bufptr[0], 0, m_bytesperline);
if (TIFFjpeg_read_scanlines(bufptr, 1) != 1)
return false;
++m_tif.m_row;
Buffer.BlockCopy(bufptr[0], 0, buffer, offset, m_bytesperline);
offset += m_bytesperline;
count -= m_bytesperline;
}
while (--nrows > 0);
}
// Close down the decompressor if we've finished the strip or tile.
return m_decompression.Output_scanline < m_decompression.Output_height || TIFFjpeg_finish_decompress();
}