C3204
2025-12-29 fec341de45f4b3fd1825807f0b3261143fa13caa
LB_SmartVision/ProcessRun/ProcessContext.cs
@@ -301,7 +301,7 @@
            return res;
        }
        public bool GetImage(Layout layout, out HImage InputImage, out HObject RecordImage)
        public bool GetImage(Layout layout, out HImage InputImage, out HImage RecordImage)
        {
            InputImage = null; RecordImage = null;
            try
@@ -337,9 +337,9 @@
                    else if (o_InputImage != null && o_InputImage is Bitmap)
                    {
                        //将Mat转换为HObject
                        using (HImage ho_RecordImage = TAlgorithm.Bitmap2HObject((Bitmap)o_InputImage))
                        using (HImage ho_RecordImage = TAlgorithm.Bitmap2HImage((Bitmap)o_InputImage))
                        {
                            if (ho_RecordImage != null)
                            if (ho_RecordImage != null && ho_RecordImage.Key != IntPtr.Zero)
                            {
                                InputImage = ho_RecordImage.Clone();
                            }
@@ -348,16 +348,16 @@
                    else if (o_InputImage != null && o_InputImage is Mat)
                    {
                        //将Mat转换为HObject
                        using (HImage ho_RecordImage = TAlgorithm.Mat2HObject((Mat)o_InputImage))
                        using (HImage ho_RecordImage = TAlgorithm.Mat2HImage((Mat)o_InputImage))
                        {
                            if (ho_RecordImage != null)
                            if (ho_RecordImage != null && ho_RecordImage.Key != IntPtr.Zero)
                            {
                                InputImage = ho_RecordImage.Clone();
                            }
                        }
                    }
                    if (InputImage != null && InputImage.IsInitialized())
                    if (InputImage != null && InputImage.Key != IntPtr.Zero && InputImage.IsInitialized())
                    {
                        InputImage.GetImageSize(out ho_ImageWidth, out ho_ImageHeight);
@@ -387,11 +387,13 @@
                    if (dicContext.ContainsKey(IndexProcessName))
                    {
                        ObjectRecord objectRecord1 = ((IProcess)dicContext[IndexProcessName]).Record;
                        if (objectRecord1 != null)
                        using (ObjectRecord objectRecord1 = ((IProcess)dicContext[IndexProcessName]).Record)
                        {
                            objectRecord1.Display(hWindowControl.HalconWindow);
                            objectRecord1.Dispose();
                            if (objectRecord1 != null)
                            {
                                objectRecord1.Display(hWindowControl.HalconWindow);
                                objectRecord1.Dispose();
                            }
                        }
                    }
                }
@@ -405,11 +407,13 @@
                    if (dicContext.ContainsKey(IndexProcessName))
                    {
                        ObjectRecord objectRecord2 = ((IProcess)dicContext[IndexProcessName]).Record;
                        if (objectRecord2 != null)
                        using (ObjectRecord objectRecord2 = ((IProcess)dicContext[IndexProcessName]).Record)
                        {
                            objectRecord2.Display(hWindowControl.HalconWindow);
                            objectRecord2.Dispose();
                            if (objectRecord2 != null)
                            {
                                objectRecord2.Display(hWindowControl.HalconWindow);
                                objectRecord2.Dispose();
                            }
                        }
                    }
                }
@@ -423,11 +427,13 @@
                    if (dicContext.ContainsKey(IndexProcessName))
                    {
                        ObjectRecord objectRecord3 = ((IProcess)dicContext[IndexProcessName]).Record;
                        if (objectRecord3 != null)
                        using (ObjectRecord objectRecord3 = ((IProcess)dicContext[IndexProcessName]).Record)
                        {
                            objectRecord3.Display(hWindowControl.HalconWindow);
                            objectRecord3.Dispose();
                            if (objectRecord3 != null)
                            {
                                objectRecord3.Display(hWindowControl.HalconWindow);
                                objectRecord3.Dispose();
                            }
                        }
                    }
                }
@@ -435,13 +441,13 @@
                if (Result)
                {
                    Msg = "运行成功";
                    HOperatorSet.SetColor(hWindowControl.HalconWindow, "green");
                    hWindowControl.HalconWindow.SetColor("green");
                }
                else
                    HOperatorSet.SetColor(hWindowControl.HalconWindow, "red");
                    hWindowControl.HalconWindow.SetColor("red");
                TAlgorithm.DispMsg(Msg, hWindowControl.HalconWindow, Result ? "green" : "red", 0, 0);
                HOperatorSet.DumpWindowImage(out RecordImage, hWindowControl.HalconWindow);
                RecordImage = hWindowControl.HalconWindow.DumpWindowImage();
                #endregion
                return true;