本文整理汇总了C#中Free.Ports.LibTiff.TIFF.tif_seek方法的典型用法代码示例。如果您正苦于以下问题:C# TIFF.tif_seek方法的具体用法?C# TIFF.tif_seek怎么用?C# TIFF.tif_seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Free.Ports.LibTiff.TIFF
的用法示例。
在下文中一共展示了TIFF.tif_seek方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TIFFSeek
// Seek to a random row+sample in a file.
static bool TIFFSeek(TIFF tif, byte[] buf, uint row, ushort sample)
{
TIFFDirectory td=tif.tif_dir;
if(row>=td.td_imagelength)
{ // out of range
TIFFErrorExt(tif.tif_clientdata, tif.tif_name, "{0}: Row out of range, max {1}", row, td.td_imagelength);
return false;
}
uint strip;
if(td.td_planarconfig==PLANARCONFIG.SEPARATE)
{
if(sample>=td.td_samplesperpixel)
{
TIFFErrorExt(tif.tif_clientdata, tif.tif_name, "{0}: Sample out of range, max {1}", sample, td.td_samplesperpixel);
return false;
}
strip=sample*td.td_stripsperimage+row/td.td_rowsperstrip;
}
else strip=row/td.td_rowsperstrip;
if(strip!=tif.tif_curstrip)
{ // different strip, refill
if(!TIFFFillStrip(tif, strip)) return false;
}
else if(row<tif.tif_row)
{
// Moving backwards within the same strip: backup
// to the start and then decode forward (below).
//
// NB: If you're planning on lots of random access within a
// strip, it's better to just read and decode the entire
// strip, and then access the decoded data in a random fashion.
if(!TIFFStartStrip(tif, strip)) return false;
}
if(row!=tif.tif_row)
{
// Seek forward to the desired row.
if(!tif.tif_seek(tif, row-tif.tif_row))
{
// if not directly seeked to, then the slow way... line by line
for(; tif.tif_row<row; tif.tif_row++)
tif.tif_decoderow(tif, buf, (int)tif.tif_scanlinesize, sample);
}
tif.tif_row=row;
}
return true;
}
示例2: TIFFWriteScanline
public static int TIFFWriteScanline(TIFF tif, byte[] buf, uint row, ushort sample)
{
string module="TIFFWriteScanline";
if(!((tif.tif_flags&TIF_FLAGS.TIFF_BEENWRITING)!=0||TIFFWriteCheck(tif, false, module))) return -1;
// Handle delayed allocation of data buffer. This
// permits it to be sized more intelligently (using
// directory information).
if(!BUFFERCHECK(tif)) return -1;
TIFFDirectory td=tif.tif_dir;
bool imagegrew=false;
// Extend image length if needed
// (but only for PlanarConfig=1).
if(row>=td.td_imagelength)
{ // extend image
if(td.td_planarconfig==PLANARCONFIG.SEPARATE)
{
TIFFErrorExt(tif.tif_clientdata, tif.tif_name, "Can not change \"ImageLength\" when using separate planes");
return -1;
}
td.td_imagelength=row+1;
imagegrew=true;
}
// Calculate strip and check for crossings.
uint strip;
if(td.td_planarconfig==PLANARCONFIG.SEPARATE)
{
if(sample>=td.td_samplesperpixel)
{
TIFFErrorExt(tif.tif_clientdata, tif.tif_name, "{0}: Sample out of range, max {1}", sample, td.td_samplesperpixel);
return -1;
}
strip=sample*td.td_stripsperimage+row/td.td_rowsperstrip;
}
else strip=row/td.td_rowsperstrip;
// Check strip array to make sure there's space. We don't support
// dynamically growing files that have data organized in separate
// bitplanes because it's too painful. In that case we require that
// the imagelength be set properly before the first write (so that the
// strips array will be fully allocated above).
if(strip>=td.td_nstrips&&!TIFFGrowStrips(tif, 1, module)) return -1;
if(strip!=tif.tif_curstrip)
{
// Changing strips -- flush any data present.
if(!TIFFFlushData(tif)) return -1;
tif.tif_curstrip=strip;
// Watch out for a growing image. The value of strips/image
// will initially be 1 (since it can't be deduced until the
// imagelength is known).
if(strip>=td.td_stripsperimage&&imagegrew) td.td_stripsperimage=TIFFhowmany(td.td_imagelength, td.td_rowsperstrip);
tif.tif_row=(strip%td.td_stripsperimage)*td.td_rowsperstrip;
if((tif.tif_flags&TIF_FLAGS.TIFF_CODERSETUP)==0)
{
if(!tif.tif_setupencode(tif)) return -1;
tif.tif_flags|=TIF_FLAGS.TIFF_CODERSETUP;
}
tif.tif_rawcc=0;
tif.tif_rawcp=0;
if(td.td_stripbytecount[strip]>0)
{
// Force TIFFAppendToStrip() to consider placing data at end of file.
tif.tif_curoff=0;
}
if(!tif.tif_preencode(tif, sample)) return -1;
tif.tif_flags|=TIF_FLAGS.TIFF_POSTENCODE;
}
// Ensure the write is either sequential or at the
// beginning of a strip (or that we can randomly
// access the data -- i.e. no encoding).
if(row!=tif.tif_row)
{
if(row<tif.tif_row)
{
// Moving backwards within the same strip:
// backup to the start and then decode
// forward (below).
tif.tif_row=(strip%td.td_stripsperimage)*td.td_rowsperstrip;
tif.tif_rawcp=0;
}
// Seek forward to the desired row.
if(!tif.tif_seek(tif, row-tif.tif_row)) return -1;
tif.tif_row=row;
}
// swab if needed - note that source buffer will be altered
tif.tif_postdecode(tif, buf, 0, (int)tif.tif_scanlinesize);
//.........这里部分代码省略.........