private bool JPEGSetupDecode()
{
TiffDirectory td = m_tif.m_dir;
InitializeLibJPEG(false, true);
Debug.Assert(m_common.IsDecompressor);
/* Read JPEGTables if it is present */
if (m_tif.fieldSet(FIELD_JPEGTABLES))
{
m_decompression.Src = new JpegTablesSource(this);
if (TIFFjpeg_read_header(false) != ReadResult.JPEG_HEADER_TABLES_ONLY)
{
Tiff.ErrorExt(m_tif, m_tif.m_clientdata, "JPEGSetupDecode", "Bogus JPEGTables field");
return false;
}
}
/* Grab parameters that are same for all strips/tiles */
m_photometric = td.td_photometric;
switch (m_photometric)
{
case Photometric.YCBCR:
m_h_sampling = td.td_ycbcrsubsampling[0];
m_v_sampling = td.td_ycbcrsubsampling[1];
break;
default:
/* TIFF 6.0 forbids subsampling of all other color spaces */
m_h_sampling = 1;
m_v_sampling = 1;
break;
}
/* Set up for reading normal data */
m_decompression.Src = new JpegStdSource(this);
m_tif.m_postDecodeMethod = Tiff.PostDecodeMethodType.pdmNone; /* override byte swapping */
return true;
}