解锁位时出现GDI +错误

时间:2018-07-20 02:10:39

标签: c# bitmap gdi+ aforge template-matching

我正在尝试使用AForge库在图像(模板匹配)中找到图像。

                ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching(0.921f);
                // find all matchings with specified above similarity

                TemplateMatch[] matchings = tm.ProcessImage(dest.Bitmap, oI.Bitmap);
                // highlight found matchings

                BitmapData data = dest.Bitmap.LockBits(
                    new Rectangle(0, 0, dest.Bitmap.Width, dest.Bitmap.Height),
                    ImageLockMode.ReadWrite, dest.Bitmap.PixelFormat);
                List<Point> points = new List<Point>();
                foreach (TemplateMatch m in matchings)
                {
                    points.Add(new Point(m.Rectangle.X, m.Rectangle.Y));

                }
                dest.Bitmap.UnlockBits(data); << Error

但是我得到一个GDI+ Exception

System.Runtime.InteropServices.ExternalException
Generic GDI+ Exception.

(此代码是从TemplateMatching示例here复制的)

注意:此代码段在BackgroundWorker内运行

0 个答案:

没有答案