C3032
2026-03-20 19bf97fd8ec4f435e9111d72969c4ebf00d97991
LB_VisionProcesses/BarcodeReaders/Huayray/HRBarcodeReader.cs
@@ -73,6 +73,7 @@
                // 创建句柄
                int nRet = _camera.eidCreateDevice_Net(sn, EidCamera.EidDeviceDataType.eidDeviceDataTypeSN);
                if (nRet != EidCamera.eidErrorOK) return false;
                if (nRet != EidCamera.eidErrorOK)
                {
                    _camera = null;
@@ -124,11 +125,15 @@
        public override bool Close()
        {
            if (!IsConnected) return true;
            try
            {
                if (IsConnected)
                {
                    StopGrabbing();
                _camera.eidCloseDevice_Net();
                _camera.eidReleaseHandle_Net();
                    _camera?.eidCloseDevice_Net();
                }
                // 无论是否连接,都尝试释放句柄
@@ -144,6 +149,7 @@
                _camera = null;
                this.IsConnected = false;
                this.SN = string.Empty;
                this.IsGrabbing = false;
                return true;
            }
@@ -210,6 +216,7 @@
        {
            try
            {
                List<string> barcodes = new List<string>();
                List<BarcodeInfo> barcodeInfos = new List<BarcodeInfo>();
                // 解析条码
                for (int i = 0; i < frameInfo.codeNum; i++)
@@ -221,6 +228,7 @@
                    string data = Marshal.PtrToStringAnsi(codeInfo.data);
                    if (!string.IsNullOrEmpty(data))
                    {
                        barcodes.Add(data);
                        BarcodeInfo info = new BarcodeInfo
                        {
                            Text = data,
@@ -236,10 +244,13 @@
                    }
                }
                // 转换图像 (如果需要)
                // 转换图像
                Bitmap bitmap = null;
                if (frameInfo.imageDataLen > 0 && frameInfo.imageData != IntPtr.Zero)
                {
                    // 这里简化处理,如果是Jpeg则直接从内存加载,如果是Raw则需转换
                    // 实际项目中可根据 frameInfo.format 进行处理
                    if (frameInfo.isJpeg)
                    {
                        byte[] managedArray = new byte[frameInfo.imageDataLen];
@@ -252,6 +263,7 @@
                }
                // 触发事件
                OnBarcodeRead(new BarcodeEventArgs(this.SN, barcodes, bitmap));
                OnBarcodeRead(new BarcodeEventArgs(this.SN, barcodeInfos, bitmap));
            }
            catch (Exception ex)