0
我一直在寻找一个可以裁剪tiff图像的例程,并且我知道了它,但它会产生很多错误。例程如下:如何在asp.net中裁剪tiff图像
Bitmap comments = null;
string input = "somepath";
// Open a Stream and decode a TIFF image
using (Stream imageStreamSource = new FileStream(input, FileMode.Open, FileAccess.Read, FileShare.Read))
{
TiffBitmapDecoder decoder = new TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapSource bitmapSource = decoder.Frames[0];
using (Bitmap b = BitmapFromSource(bitmapSource))
{
Rectangle cropRect = new Rectangle(169, 1092, 567, 200);
comments = new Bitmap(cropRect.Width, cropRect.Height);
//first cropping
using (Graphics g = Graphics.FromImage(comments))
{
g.DrawImage(b, new Rectangle(0, 0, comments.Width, comments.Height),
cropRect,
GraphicsUnit.Pixel);
}
}
}
当我尝试编译它时,出现错误。我试图添加引用到许多搜索谷歌程序集,但无法解决它。我从这个网址得到了这段代码:
http://snipplr.com/view/63053/
我在寻找建议。
它肯定有助于增加您得到的错误.... – rene
此外,请提供有关TIFF图像本身(彩色,多帧等)的更多信息。开箱即用的GDI +/.NET在某些类型的TIFF文件中遇到了麻烦。 – HackedByChinese