C# 分割tif文件问题
Image img = Image.FromFile(fileName);
Guid guid = (Guid)img.FrameDimensionsList.GetValue(0);
FrameDimension dimension = new FrameDimension(guid);
int totalPage = img.GetFrameCount(dimension);
MessageBox.Show("共" + totalPage + "页");
for (int i = 0; i < totalPage; i++)
{
img.SelectActiveFrame(dimension, i);
int num = i + 1;
img.Save(@"d:\test2\jpeg" + num + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
} 拆分tif文件时,如果tif文件里有压缩jpg的图片,就导致拆分出异常,这个应该怎么解决啊?
------最佳解决方案--------------------
try
{
Bitmap img = new BitMap("c:/1.TIF")//写上你的地址,因为我担心Image会报错
Guid guid = (Guid)img.FrameDimensionsList.GetValue(0);
FrameDimension dimension = new FrameDimension(guid);
int totalPage = img.GetFrameCount(dimension);
MessageBox.Show("共" + totalPage + "页");
for (int i = 0; i < totalPage; i++)
{
img.SelectActiveFrame(dimension, i);
int num = i + 1;
img.Save(@"d:\test2\jpeg" + num + ".jpg", System.Drawing.Imaging.ImageFormat.Gif);
}
}
catch
{
}
}
------其他解决方案--------------------
不知道你是不是用的win7操作系统,可能没有取得管理员权限所致。XP情况下是可以的
------其他解决方案--------------------记得结贴额 &n