本文整理汇总了C#中BitMiracle.LibTiff.Classic.Tiff.ReadEncodedStrip方法的典型用法代码示例。如果您正苦于以下问题:C# Tiff.ReadEncodedStrip方法的具体用法?C# Tiff.ReadEncodedStrip怎么用?C# Tiff.ReadEncodedStrip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitMiracle.LibTiff.Classic.Tiff
的用法示例。
在下文中一共展示了Tiff.ReadEncodedStrip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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());
//.........这里部分代码省略.........
示例2: 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;
}
示例3: readStrip
private static int readStrip(Tiff image, int stripNumber, byte[] buffer, int offset, bool encoded)
{
if (encoded)
return image.ReadEncodedStrip(stripNumber, buffer, offset, buffer.Length - offset);
else
return image.ReadRawStrip(stripNumber, buffer, offset, buffer.Length - offset);
}