本文整理汇总了C#中BitMiracle.LibTiff.Classic.Tiff.NumberOfStrips方法的典型用法代码示例。如果您正苦于以下问题:C# Tiff.NumberOfStrips方法的具体用法?C# Tiff.NumberOfStrips怎么用?C# Tiff.NumberOfStrips使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitMiracle.LibTiff.Classic.Tiff
的用法示例。
在下文中一共展示了Tiff.NumberOfStrips方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: cpDecodedStrips
/*
* Strip -> strip for change in encoding.
*/
bool cpDecodedStrips(Tiff inImage, Tiff outImage, int imagelength, int imagewidth, short spp)
{
int stripsize = inImage.StripSize();
byte[] buf = new byte[stripsize];
int ns = inImage.NumberOfStrips();
int row = 0;
for (int s = 0; s < ns; s++)
{
int cc = (row + m_rowsperstrip > imagelength) ? inImage.VStripSize(imagelength - row) : stripsize;
if (inImage.ReadEncodedStrip(s, buf, 0, cc) < 0 && !m_ignore)
{
Tiff.Error(inImage.FileName(), "Error, can't read strip {0}", s);
return false;
}
if (outImage.WriteEncodedStrip(s, buf, cc) < 0)
{
Tiff.Error(outImage.FileName(), "Error, can't write strip {0}", s);
return false;
}
row += m_rowsperstrip;
}
return true;
}
示例2: read_tiff_data
//.........这里部分代码省略.........
result = input.GetField(TiffTag.XRESOLUTION);
if (result == null)
m_tiff_xres = 0.0f;
else
m_tiff_xres = result[0].ToFloat();
result = input.GetField(TiffTag.YRESOLUTION);
if (result == null)
m_tiff_yres = 0.0f;
else
m_tiff_yres = result[0].ToFloat();
result = input.GetFieldDefaulted(TiffTag.RESOLUTIONUNIT);
m_tiff_resunit = (ResUnit)result[0].ToByte();
if (m_tiff_resunit == ResUnit.CENTIMETER)
{
m_tiff_xres *= 2.54F;
m_tiff_yres *= 2.54F;
}
else if (m_tiff_resunit != ResUnit.INCH && m_pdf_centimeters)
{
m_tiff_xres *= 2.54F;
m_tiff_yres *= 2.54F;
}
compose_pdf_page();
m_pdf_transcode = t2p_transcode_t.T2P_TRANSCODE_ENCODE;
if (!m_pdf_nopassthrough)
{
if (m_tiff_compression == Compression.CCITTFAX4)
{
if (input.IsTiled() || (input.NumberOfStrips() == 1))
{
m_pdf_transcode = t2p_transcode_t.T2P_TRANSCODE_RAW;
m_pdf_compression = t2p_compress_t.T2P_COMPRESS_G4;
}
}
if (m_tiff_compression == Compression.ADOBE_DEFLATE || m_tiff_compression == Compression.DEFLATE)
{
if (input.IsTiled() || (input.NumberOfStrips() == 1))
{
m_pdf_transcode = t2p_transcode_t.T2P_TRANSCODE_RAW;
m_pdf_compression = t2p_compress_t.T2P_COMPRESS_ZIP;
}
}
if (m_tiff_compression == Compression.JPEG)
{
m_pdf_transcode = t2p_transcode_t.T2P_TRANSCODE_RAW;
m_pdf_compression = t2p_compress_t.T2P_COMPRESS_JPEG;
}
}
if (m_pdf_transcode != t2p_transcode_t.T2P_TRANSCODE_RAW)
m_pdf_compression = m_pdf_defaultcompression;
if (m_pdf_defaultcompression == t2p_compress_t.T2P_COMPRESS_JPEG)
{
if ((m_pdf_colorspace & t2p_cs_t.T2P_CS_PALETTE) != 0)
{
m_pdf_sample = (t2p_sample_t)(m_pdf_sample | t2p_sample_t.T2P_SAMPLE_REALIZE_PALETTE);
m_pdf_colorspace = (t2p_cs_t)(m_pdf_colorspace ^ t2p_cs_t.T2P_CS_PALETTE);
m_tiff_pages[m_pdf_page].page_extra--;
示例3: readwrite_pdf_image
/*
This function reads the raster image data from the input TIFF for an image and writes
the data to the output PDF XObject image dictionary stream. It returns the amount written
or zero on error.
*/
private int readwrite_pdf_image(Tiff input)
{
byte[] buffer = null;
int bufferoffset = 0;
int stripcount = 0;
int max_striplength = 0;
FieldValue[] result = null;
if (m_pdf_transcode == t2p_transcode_t.T2P_TRANSCODE_RAW)
{
if (m_pdf_compression == t2p_compress_t.T2P_COMPRESS_G4)
{
buffer = new byte [m_tiff_datasize];
input.ReadRawStrip(0, buffer, 0, m_tiff_datasize);
if (m_tiff_fillorder == FillOrder.LSB2MSB)
{
/*
* make sure is lsb-to-msb
* bit-endianness fill order
*/
Tiff.ReverseBits(buffer, m_tiff_datasize);
}
writeToFile(buffer, m_tiff_datasize);
return m_tiff_datasize;
}
if (m_pdf_compression == t2p_compress_t.T2P_COMPRESS_ZIP)
{
buffer = new byte [m_tiff_datasize];
input.ReadRawStrip(0, buffer, 0, m_tiff_datasize);
if (m_tiff_fillorder == FillOrder.LSB2MSB)
Tiff.ReverseBits(buffer, m_tiff_datasize);
writeToFile(buffer, m_tiff_datasize);
return m_tiff_datasize;
}
if (m_tiff_compression == Compression.JPEG)
{
buffer = new byte [m_tiff_datasize];
result = input.GetField(TiffTag.JPEGTABLES);
if (result != null)
{
int count = result[0].ToInt();
byte[] jpt = result[1].ToByteArray();
if (count > 4)
{
Buffer.BlockCopy(jpt, 0, buffer, 0, count);
bufferoffset += count - 2;
}
}
stripcount = input.NumberOfStrips();
result = input.GetField(TiffTag.STRIPBYTECOUNTS);
int[] sbc = result[0].ToIntArray();
for (int i = 0; i < stripcount; i++)
{
if (sbc[i] > max_striplength)
max_striplength = sbc[i];
}
byte[] stripbuffer = new byte [max_striplength];
for (int i = 0; i < stripcount; i++)
{
int striplength = input.ReadRawStrip(i, stripbuffer, 0, -1);
if (!process_jpeg_strip(stripbuffer, striplength, buffer, ref bufferoffset, stripcount, i, m_tiff_length))
{
Tiff.Error(Tiff2PdfConstants.TIFF2PDF_MODULE,
"Can't process JPEG data in input file {0}", input.FileName());
m_error = true;
return 0;
}
}
buffer[bufferoffset++] = 0xff;
buffer[bufferoffset++] = 0xd9;
writeToFile(buffer, bufferoffset);
return bufferoffset;
}
}
int stripsize = 0;
if (m_pdf_sample == t2p_sample_t.T2P_SAMPLE_NOTHING)
{
buffer = new byte [m_tiff_datasize];
stripsize = input.StripSize();
stripcount = input.NumberOfStrips();
for (int i = 0; i < stripcount; i++)
{
int read = input.ReadEncodedStrip(i, buffer, bufferoffset, stripsize);
if (read == -1)
{
Tiff.Error(Tiff2PdfConstants.TIFF2PDF_MODULE,
"Error on decoding strip {0} of {1}", i, input.FileName());
//.........这里部分代码省略.........
示例4: 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();
//.........这里部分代码省略.........
示例5: read_tiff_size
/*
This function returns the necessary size of a data buffer to contain the raw or
uncompressed image data from the input TIFF for a page.
*/
private void read_tiff_size(Tiff input)
{
if (m_pdf_transcode == t2p_transcode_t.T2P_TRANSCODE_RAW)
{
FieldValue[] result = null;
if (m_pdf_compression == t2p_compress_t.T2P_COMPRESS_G4)
{
result = input.GetField(TiffTag.STRIPBYTECOUNTS);
int[] sbc = result[0].ToIntArray();
m_tiff_datasize = sbc[0];
return;
}
if (m_pdf_compression == t2p_compress_t.T2P_COMPRESS_ZIP)
{
result = input.GetField(TiffTag.STRIPBYTECOUNTS);
int[] sbc = result[0].ToIntArray();
m_tiff_datasize = sbc[0];
return;
}
if (m_tiff_compression == Compression.JPEG)
{
result = input.GetField(TiffTag.JPEGTABLES);
if (result != null)
{
int count = result[0].ToInt();
if (count > 4)
{
m_tiff_datasize += count;
m_tiff_datasize -= 2; /* don't use EOI of header */
}
}
else
{
m_tiff_datasize = 2; /* SOI for first strip */
}
int stripcount = input.NumberOfStrips();
int[] sbc = null;
result = input.GetField(TiffTag.STRIPBYTECOUNTS);
if (result == null)
{
Tiff.Error(Tiff2PdfConstants.TIFF2PDF_MODULE,
"Input file {0} missing field: STRIPBYTECOUNTS",
input.FileName());
m_error = true;
return;
}
else
sbc = result[0].ToIntArray();
for (int i = 0; i < stripcount; i++)
{
m_tiff_datasize += sbc[i];
m_tiff_datasize -= 4; /* don't use SOI or EOI of strip */
}
m_tiff_datasize += 2; /* use EOI of last strip */
return;
}
}
m_tiff_datasize = input.ScanlineSize() * m_tiff_length;
if (m_tiff_planar == PlanarConfig.SEPARATE)
m_tiff_datasize *= m_tiff_samplesperpixel;
}