本文整理汇总了C#中BitMiracle.LibTiff.Classic.Tiff.SetDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# Tiff.SetDirectory方法的具体用法?C# Tiff.SetDirectory怎么用?C# Tiff.SetDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitMiracle.LibTiff.Classic.Tiff
的用法示例。
在下文中一共展示了Tiff.SetDirectory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: read_tiff_data
/*
This function sets the input directory to the directory of a given
page and determines information about the image. It checks
the image characteristics to determine if it is possible to convert
the image data into a page of PDF output, setting values of the T2P
struct for this page. It determines what color space is used in
the output PDF to represent the image.
It determines if the image can be converted as raw data without
requiring transcoding of the image data.
*/
private void read_tiff_data(Tiff input)
{
m_pdf_transcode = t2p_transcode_t.T2P_TRANSCODE_ENCODE;
m_pdf_sample = t2p_sample_t.T2P_SAMPLE_NOTHING;
m_pdf_switchdecode = m_pdf_colorspace_invert;
input.SetDirectory(m_tiff_pages[m_pdf_page].page_directory);
FieldValue[] result = input.GetField(TiffTag.IMAGEWIDTH);
m_tiff_width = result[0].ToInt();
if (m_tiff_width == 0)
{
Tiff.Error(Tiff2PdfConstants.TIFF2PDF_MODULE, "No support for {0} with zero width", input.FileName());
m_error = true;
return;
}
result = input.GetField(TiffTag.IMAGELENGTH);
m_tiff_length = result[0].ToInt();
if (m_tiff_length == 0)
{
Tiff.Error(Tiff2PdfConstants.TIFF2PDF_MODULE,
"No support for {0} with zero length", input.FileName());
m_error = true;
return;
}
result = input.GetField(TiffTag.COMPRESSION);
if (result == null)
{
Tiff.Error(Tiff2PdfConstants.TIFF2PDF_MODULE,
"No support for {0} with no compression tag", input.FileName());
m_error = true;
return;
}
else
m_tiff_compression = (Compression)result[0].ToInt();
if (!input.IsCodecConfigured(m_tiff_compression))
{
Tiff.Error(Tiff2PdfConstants.TIFF2PDF_MODULE,
"No support for {0} with compression type {1}: not configured",
input.FileName(), m_tiff_compression);
m_error = true;
return;
}
result = input.GetFieldDefaulted(TiffTag.BITSPERSAMPLE);
m_tiff_bitspersample = result[0].ToShort();
switch (m_tiff_bitspersample)
{
case 1:
case 2:
case 4:
case 8:
break;
case 0:
Tiff.Warning(Tiff2PdfConstants.TIFF2PDF_MODULE,
"Image {0} has 0 bits per sample, assuming 1", input.FileName());
m_tiff_bitspersample = 1;
break;
default:
Tiff.Error(Tiff2PdfConstants.TIFF2PDF_MODULE,
"No support for {0} with {1} bits per sample",
input.FileName(), m_tiff_bitspersample);
m_error = true;
return;
}
result = input.GetFieldDefaulted(TiffTag.SAMPLESPERPIXEL);
m_tiff_samplesperpixel = result[0].ToShort();
if (m_tiff_samplesperpixel > 4)
{
Tiff.Error(Tiff2PdfConstants.TIFF2PDF_MODULE,
"No support for {0} with {1} samples per pixel", input.FileName(), m_tiff_samplesperpixel);
m_error = true;
return;
}
if (m_tiff_samplesperpixel == 0)
{
Tiff.Warning(Tiff2PdfConstants.TIFF2PDF_MODULE,
"Image {0} has 0 samples per pixel, assuming 1", input.FileName());
m_tiff_samplesperpixel = 1;
}
result = input.GetField(TiffTag.SAMPLEFORMAT);
//.........这里部分代码省略.........
示例2: read_tiff_init
/*
This function scans the input TIFF file for pages. It attempts
to determine which IFD's of the TIFF file contain image document
pages. For each, it gathers some information that has to do
with the output of the PDF document as a whole.
*/
private void read_tiff_init(Tiff input)
{
short directorycount = input.NumberOfDirectories();
m_tiff_pages = new T2P_PAGE [directorycount];
for (int p = 0; p < directorycount; p++)
m_tiff_pages[p] = new T2P_PAGE();
FieldValue[] result = null;
for (short i = 0; i < directorycount; i++)
{
int subfiletype = 0;
if (!input.SetDirectory(i))
{
Tiff.Error(Tiff2PdfConstants.TIFF2PDF_MODULE,
"Can't set directory {0} of input file {1}", i, input.FileName());
return;
}
result = input.GetField(TiffTag.PAGENUMBER);
if (result != null)
{
short pagen = result[0].ToShort();
short paged = result[1].ToShort();
if ((pagen > paged) && (paged != 0))
m_tiff_pages[m_tiff_pagecount].page_number = paged;
else
m_tiff_pages[m_tiff_pagecount].page_number = pagen;
}
else
{
result = input.GetField(TiffTag.SUBFILETYPE);
if (result != null)
{
subfiletype = result[0].ToInt();
if ((((FileType)subfiletype & FileType.PAGE) == 0) && (subfiletype != 0))
continue;
}
else
{
result = input.GetField(TiffTag.OSUBFILETYPE);
if (result != null)
{
subfiletype = result[0].ToInt();
if (((OFileType)subfiletype != OFileType.IMAGE) && ((OFileType)subfiletype != OFileType.PAGE) && (subfiletype != 0))
continue;
}
}
m_tiff_pages[m_tiff_pagecount].page_number = m_tiff_pagecount;
}
m_tiff_pages[m_tiff_pagecount].page_directory = i;
if (input.IsTiled())
m_tiff_pages[m_tiff_pagecount].page_tilecount = input.NumberOfTiles();
m_tiff_pagecount++;
}
IComparer myComparer = new cmp_t2p_page();
Array.Sort(m_tiff_pages, myComparer);
for (short i = 0; i < m_tiff_pagecount; i++)
{
m_pdf_xrefcount += 5;
input.SetDirectory(m_tiff_pages[i].page_directory);
result = input.GetField(TiffTag.PHOTOMETRIC);
if ((result != null && ((Photometric)result[0].ToInt() == Photometric.PALETTE)) || input.GetField(TiffTag.INDEXED) != null)
{
m_tiff_pages[i].page_extra++;
m_pdf_xrefcount++;
}
result = input.GetField(TiffTag.COMPRESSION);
if (result != null)
{
Compression xuint16 = (Compression)result[0].ToInt();
if ((xuint16 == Compression.DEFLATE || xuint16 == Compression.ADOBE_DEFLATE)
&& ((m_tiff_pages[i].page_tilecount != 0) || input.NumberOfStrips() == 1)
&& !m_pdf_nopassthrough)
{
if (m_pdf_minorversion < 2)
m_pdf_minorversion = 2;
}
}
result = input.GetField(TiffTag.TRANSFERFUNCTION);
if (result != null)
{
m_tiff_transferfunction[0] = result[0].GetBytes();
//.........这里部分代码省略.........