赞
踩
由于Bitmap 在转化时使用BitmapData数据,BitmapData数据无法Dispose, 所以在使用时,使用using:
try { using (Bitmap b = bmp.Clone() as Bitmap) { if (bmp == null) { image = null; return; }; Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); BitmapData srcBmpData = b.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed); HObject _image; HOperatorSet.GenImage1(out _image, "byte", b.Width, b.Height, srcBmpData.Scan0); image = new HImage(_image); _image.Dispose(); b.UnlockBits(srcBmpData); srcBmpData = null; } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.Source); Console.WriteLine(ex.StackTrace); image = null; }
HObject obj = new HObject(image);
HOperatorSet.ZoomImageFactor(obj, out hoImageZoomed, scaleR, scaleC, "constant");
obj.Dispose();
不能直接使用
HOperatorSet.ZoomImageFactor(new HObject(image), out hoImageZoomed, scaleR, scaleC, "constant");
切换配方时,会重新添加检测界面模块,需要先释放
tabPageSettingList.ForEach(b => b.Dispose());
tabPageSettingList.Clear();
image = image.ScaleImageMax();
改为
HImage scaleImg = new HImage();
if (image != null)
{
scaleImg = image.ScaleImageMax();
}
.....
scaleImg.Dispose();
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。