本文整理汇总了C#中BitMiracle.LibTiff.Classic.Tiff.DefaultStripSize方法的典型用法代码示例。如果您正苦于以下问题:C# Tiff.DefaultStripSize方法的具体用法?C# Tiff.DefaultStripSize怎么用?C# Tiff.DefaultStripSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitMiracle.LibTiff.Classic.Tiff
的用法示例。
在下文中一共展示了Tiff.DefaultStripSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Copy
//.........这里部分代码省略.........
* is not specified, use either the value from the
* input image or, if nothing is defined, use the
* library default.
*/
if (m_tilewidth == -1)
{
result = inImage.GetFieldDefaulted(TiffTag.TILEWIDTH);
if (result != null)
m_tilewidth = result[0].ToInt();
}
if (m_tilelength == -1)
{
result = inImage.GetFieldDefaulted(TiffTag.TILELENGTH);
if (result != null)
m_tilelength = result[0].ToInt();
}
outImage.DefaultTileSize(ref m_tilewidth, ref m_tilelength);
outImage.SetField(TiffTag.TILEWIDTH, m_tilewidth);
outImage.SetField(TiffTag.TILELENGTH, m_tilelength);
}
else
{
/*
* RowsPerStrip is left unspecified: use either the
* value from the input image or, if nothing is defined,
* use the library default.
*/
if (m_rowsperstrip == 0)
{
result = inImage.GetField(TiffTag.ROWSPERSTRIP);
if (result == null)
m_rowsperstrip = outImage.DefaultStripSize(m_rowsperstrip);
else
m_rowsperstrip = result[0].ToInt();
if (m_rowsperstrip > length && m_rowsperstrip != -1)
m_rowsperstrip = length;
}
else if (m_rowsperstrip == -1)
m_rowsperstrip = length;
outImage.SetField(TiffTag.ROWSPERSTRIP, m_rowsperstrip);
}
if (m_config != PlanarConfig.UNKNOWN)
outImage.SetField(TiffTag.PLANARCONFIG, m_config);
else
{
result = inImage.GetField(TiffTag.PLANARCONFIG);
if (result != null)
{
m_config = (PlanarConfig)result[0].ToShort();
outImage.SetField(TiffTag.PLANARCONFIG, m_config);
}
}
if (samplesperpixel <= 4)
copyTag(inImage, outImage, TiffTag.TRANSFERFUNCTION, 4, TiffType.SHORT);
copyTag(inImage, outImage, TiffTag.COLORMAP, 4, TiffType.SHORT);
/* SMinSampleValue & SMaxSampleValue */
switch (m_compression)
{
示例2: cvt_whole_image
/// <summary>
/// Read the whole image into one big RGBA buffer and then write out
/// strips from that. This is using the traditional TIFFReadRGBAImage()
/// API that we trust.
/// </summary>
private bool cvt_whole_image(Tiff inImage, Tiff outImage, int width, int height)
{
int pixel_count = width * height;
/* XXX: Check the integer overflow. */
if (width == 0 || height == 0 || (pixel_count / width) != height)
{
Tiff.Error(inImage.FileName(),
"Malformed input file; can't allocate buffer for raster of {0}x{1} size",
width, height);
return false;
}
m_rowsPerStrip = outImage.DefaultStripSize(m_rowsPerStrip);
outImage.SetField(TiffTag.ROWSPERSTRIP, m_rowsPerStrip);
int[] raster = new int[pixel_count];
/* Read the image in one chunk into an RGBA array */
if (!inImage.ReadRGBAImageOriented(width, height, raster, Orientation.TOPLEFT, false))
return false;
/*
* Do we want to strip away alpha components?
*/
byte[] rasterBytes;
int rasterByteSize;
if (m_noAlpha)
{
rasterByteSize = pixel_count * 3;
rasterBytes = new byte[rasterByteSize];
for (int i = 0, rasterBytesPos = 0; i < pixel_count; i++)
{
byte[] bytes = BitConverter.GetBytes(raster[i]);
rasterBytes[rasterBytesPos++] = bytes[0];
rasterBytes[rasterBytesPos++] = bytes[1];
rasterBytes[rasterBytesPos++] = bytes[2];
}
}
else
{
rasterByteSize = pixel_count * 4;
rasterBytes = new byte[rasterByteSize];
Buffer.BlockCopy(raster, 0, rasterBytes, 0, rasterByteSize);
}
/*
* Write out the result in strips
*/
for (int row = 0; row < height; row += m_rowsPerStrip)
{
int bytes_per_pixel;
if (m_noAlpha)
bytes_per_pixel = 3;
else
bytes_per_pixel = 4;
int rows_to_write;
if (row + m_rowsPerStrip > height)
rows_to_write = height - row;
else
rows_to_write = m_rowsPerStrip;
int offset = bytes_per_pixel * row * width;
int count = bytes_per_pixel * rows_to_write * width;
if (outImage.WriteEncodedStrip(row / m_rowsPerStrip, rasterBytes, offset, count) == -1)
return false;
}
return true;
}