问题描述
我试图用吧code识别软件,并需要遍历所有帧中的TIFF文件。我很困惑的几个要点:1)什么是一个框架,为什么它有一个GUID,为什么我需要遍历框架?我似乎无法找到大量的文档资料。
2)code投一次迭代后无效的参数异常。我不知道为什么;从逻辑上讲,我不能超过帧数,所以不知道它怎么可能是一个无效的参数,假设这就是问题所在。
为System.Drawing.Image IMG = System.Drawing.Image.FromStream(MEMS);
的Guid GUID = img.FrameDimensionsList [0];
FrameDimension尺寸=新FrameDimension(GUID);
INT totalFrame = img.GetFrameCount(尺寸);
的foreach(INT I = 0; I< totalFrame;我++)
{
img.SelectActiveFrame(尺寸,I);
}
帧通常重相同的图像文件内的present多个图像。例如,动画GIF具有沿着时间维度几个帧。一个图标可能沿着分辨率尺寸(即不同的图像不同的分辨率),多帧图像。
例如,这code显示GIF动画的所有帧(在LinqPad):
变种形象= Image.FromFile(路径);
诠释帧= image.GetFrameCount(FrameDimension.Time);
的for(int i = 0; I<帧;我++)
{
image.SelectActiveFrame(FrameDimension.Time,我);
image.Dump();
}
在你的code,你正在做的 FrameDimensionList
的第一个元素,不知道哪个维度它重新presents。尝试使用 FrameDimension.Page
,而不是(假设你需要遍历页尺寸)。
I'm trying to use Bar Code Recognition software and need to iterate over all the frames in a tiff file. I am confused on several points:1) What is a frame, why does it have a guid and why do I need to iterate over frames? I can't seem to find a lot of documentation.
2) The code throws an invalid parameter exception after one iteration. I'm not sure why; logically, i cannot exceed the frame count, so not sure how it could be an invalid parameter, assuming that is the problem.
System.Drawing.Image img = System.Drawing.Image.FromStream(mems);
Guid guid = img.FrameDimensionsList[0];
FrameDimension dimension = new FrameDimension(guid);
int totalFrame = img.GetFrameCount(dimension);
foreach(int i =0; i < totalFrame; i++)
{
img.SelectActiveFrame(dimension, i);
}
Frames typically represent several images within the same image file. For instance, an animated GIF has several frames along the time dimension. An icon might have several frames along the resolution dimension (i.e. distinct images for different resolutions).
For instance, this code displays all frames in an animated GIF (in LinqPad):
var image = Image.FromFile(path);
int frames = image.GetFrameCount(FrameDimension.Time);
for (int i = 0; i < frames; i++)
{
image.SelectActiveFrame(FrameDimension.Time, i);
image.Dump();
}
In your code, you're taking the first element from FrameDimensionList
, without knowing which dimension it represents. Try using FrameDimension.Page
instead (assuming you need to iterate over the "page" dimension).
这篇关于试图遍历一个System.Drawing.Image对象帧,将引发无效的参数异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!