C3204
2026-01-08 913c2f4f74d58617a9e23e63da0094295b722c8b
LB_VisionProcesses/Cameras/HRCameras/HRCamera.cs
@@ -1,4 +1,6 @@
using MVSDK_Net;
using HalconDotNet;
using LB_SmartVisionCommon;
using MVSDK_Net;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -26,6 +28,16 @@
        private Thread _callbackThread; // 回调处理线程
        private List<IMVDefine.IMV_Frame> _frameList; // 图像缓存列表
        private readonly object _frameLock = new object(); // 帧缓存锁
        private IMVDefine.IMV_EPixelType type = IMVDefine.IMV_EPixelType.gvspPixelMono8;
        private IMVDefine.IMV_PixelConvertParam stPixelConvertParam = new IMVDefine.IMV_PixelConvertParam();
        HObject Hobj = new HObject();
        IntPtr pTemp = IntPtr.Zero;
        IntPtr pConvertDstBuffer = IntPtr.Zero;
        int nConvertBufSize = 0;
        private IMVDefine.IMV_FrameCallBack frameCallBack;
        // CopyMemory API声明
        [System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "RtlMoveMemory")]
@@ -92,13 +104,15 @@
                {
                    // 记录日志或抛出异常
                    //throw new Exception($"枚举设备失败,错误码:{result}");
                    Debug.WriteLine("枚举设备失败!");
                    AsyncLogHelper.Error("枚举设备失败!");
                    System.Diagnostics.Debug.WriteLine("枚举设备失败!");
                }
            }
            catch (Exception ex)
            {
                // 记录错误日志
                System.Diagnostics.Debug.WriteLine($"获取相机列表失败:{ex.Message}");
                AsyncLogHelper.Error($"获取相机列表失败:{ex.Message}");
                throw;
            }
@@ -145,6 +159,7 @@
                if (cameraIndex == -1)
                {
                    AsyncLogHelper.Error($"未找到序列号为 {SN} 的相机");
                    throw new Exception($"未找到序列号为 {SN} 的相机");
                }
@@ -152,6 +167,7 @@
                int result = _camera.IMV_CreateHandle(IMVDefine.IMV_ECreateHandleMode.modeByIndex, cameraIndex);
                if (result != IMVDefine.IMV_OK)
                {
                    AsyncLogHelper.Error($"创建设备句柄失败,错误码:{result}");
                    throw new Exception($"创建设备句柄失败,错误码:{result}");
                }
                _handleCreated = true;
@@ -160,6 +176,7 @@
                result = _camera.IMV_Open();
                if (result != IMVDefine.IMV_OK)
                {
                    AsyncLogHelper.Error($"打开相机失败,错误码:{result}");
                    throw new Exception($"打开相机失败,错误码:{result}");
                }
@@ -167,17 +184,121 @@
                this.SN = SN;
                isGrabbing = false;
                // 设置缓存个数为8
                _camera.IMV_SetBufferCount(8);
                // 注册数据帧回调函数
                // Register data frame callback function
                frameCallBack = onGetFrame;
                int res = _camera.IMV_AttachGrabbing(frameCallBack, IntPtr.Zero);
                if (res != IMVDefine.IMV_OK)
                {
                    System.Diagnostics.Debug.WriteLine("Attach grabbing failed! ErrorCode:[{0}]", res);
                    AsyncLogHelper.Error("Attach grabbing failed! ErrorCode:[{0}]" + res);
                }
                // 设置缓存个数为12
                _camera.IMV_SetBufferCount(12);
                return true;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"初始化相机失败:{ex.Message}");
                AsyncLogHelper.Error($"初始化相机失败:{ex.Message}");
                return false;
            }
        }
        // 数据帧回调函数
        // Data frame callback function
        private void onGetFrame(ref IMVDefine.IMV_Frame frame, IntPtr pUser)
        {
            if (frame.frameHandle == IntPtr.Zero)
            {
                AsyncLogHelper.Info(SN + "frame is NULL");
                return;
            }
            try
            {
                Bitmap bitmap = ConvertFrameToBitmap(frame);
                // 释放帧数据
                // release frame
                _camera.IMV_ReleaseFrame(ref frame);
                CallBackImg = (Bitmap)bitmap.Clone();
                if (CallBackImg == null)
                {
                    return;
                }
                if (GetTriggerMode(out TriggerMode mode, out TriggerSource source))
                {
                    if (mode == TriggerMode.On && source != TriggerSource.Software)
                        TriggerRunMessageReceived?.Invoke(SN, source.ToString());  // 触发运行事件
                }
                bitmap.Dispose();
            }
            catch { }
            AsyncLogHelper.Info(SN + "Get frame blockId = {0}" + frame.frameInfo.blockId);
        }
        /// <summary>
        /// 图像是否为Mono格式
        /// </summary>
        /// <param name="enType"></param>
        /// <returns></returns>
        private bool IsMonoPixelFormat(IMVDefine.IMV_EPixelType enType)
        {
            switch (enType)
            {
                case IMVDefine.IMV_EPixelType.gvspPixelMono8:
                case IMVDefine.IMV_EPixelType.gvspPixelMono10:
                case IMVDefine.IMV_EPixelType.gvspPixelMono10Packed:
                case IMVDefine.IMV_EPixelType.gvspPixelMono12:
                case IMVDefine.IMV_EPixelType.gvspPixelMono12Packed:
                    return true;
                default:
                    return false;
            }
        }
        /// <summary>
        /// 图像是否为彩色
        /// </summary>
        /// <param name="enType"></param>
        /// <returns></returns>
        private bool IsColorPixelFormat(IMVDefine.IMV_EPixelType enType)
        {
            switch (enType)
            {
                case IMVDefine.IMV_EPixelType.gvspPixelRGB8:
                case IMVDefine.IMV_EPixelType.gvspPixelBGR8:
                case IMVDefine.IMV_EPixelType.gvspPixelRGBA8:
                case IMVDefine.IMV_EPixelType.gvspPixelBGRA8:
                case IMVDefine.IMV_EPixelType.gvspPixelYUV422_8:
                case IMVDefine.IMV_EPixelType.gvspPixelYUV422_8_UYVY:
                case IMVDefine.IMV_EPixelType.gvspPixelBayGR8:
                case IMVDefine.IMV_EPixelType.gvspPixelBayRG8:
                case IMVDefine.IMV_EPixelType.gvspPixelBayGB8:
                case IMVDefine.IMV_EPixelType.gvspPixelBayBG8:
                case IMVDefine.IMV_EPixelType.gvspPixelBayGB10:
                case IMVDefine.IMV_EPixelType.gvspPixelBayGB10Packed:
                case IMVDefine.IMV_EPixelType.gvspPixelBayBG10:
                case IMVDefine.IMV_EPixelType.gvspPixelBayBG10Packed:
                case IMVDefine.IMV_EPixelType.gvspPixelBayRG10:
                case IMVDefine.IMV_EPixelType.gvspPixelBayRG10Packed:
                case IMVDefine.IMV_EPixelType.gvspPixelBayGR10:
                case IMVDefine.IMV_EPixelType.gvspPixelBayGR10Packed:
                case IMVDefine.IMV_EPixelType.gvspPixelBayGB12:
                case IMVDefine.IMV_EPixelType.gvspPixelBayGB12Packed:
                case IMVDefine.IMV_EPixelType.gvspPixelBayBG12:
                case IMVDefine.IMV_EPixelType.gvspPixelBayBG12Packed:
                case IMVDefine.IMV_EPixelType.gvspPixelBayRG12:
                case IMVDefine.IMV_EPixelType.gvspPixelBayRG12Packed:
                case IMVDefine.IMV_EPixelType.gvspPixelBayGR12:
                case IMVDefine.IMV_EPixelType.gvspPixelBayGR12Packed:
                    return true;
                default:
                    return false;
            }
        }
        /// <summary>
        /// 关闭相机设备
@@ -203,6 +324,7 @@
                    if (result != IMVDefine.IMV_OK)
                    {
                        System.Diagnostics.Debug.WriteLine($"关闭相机失败,错误码:{result}");
                        AsyncLogHelper.Info(SN + $"关闭相机失败,错误码:{result}");
                    }
                }
@@ -233,6 +355,7 @@
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"关闭相机失败:{ex.Message}");
                AsyncLogHelper.Info(SN + $"关闭相机失败:{ex.Message}");
                return false;
            }
        }
@@ -251,7 +374,8 @@
            {
                if (_camera == null || !_camera.IMV_IsOpen())
                {
                    throw new Exception("相机未打开");
                    AsyncLogHelper.Error(SN + "相机未打开");
                    throw new Exception(SN + "相机未打开");
                }
                // 停止现有采集
@@ -264,7 +388,8 @@
                int result = _camera.IMV_StartGrabbing();
                if (result != IMVDefine.IMV_OK)
                {
                    throw new Exception($"启动采集失败,错误码:{result}");
                    AsyncLogHelper.Error(SN + $"启动采集失败,错误码:{result}");
                    throw new Exception(SN + $"启动采集失败,错误码:{result}");
                }
                _isGrabbing = true;
@@ -280,7 +405,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"启动采集失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"启动采集失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"启动采集失败:{ex.Message}");
                _isGrabbing = false;
                isGrabbing = false;
                return false;
@@ -310,7 +436,8 @@
                int result = _camera.IMV_StopGrabbing();
                if (result != IMVDefine.IMV_OK)
                {
                    System.Diagnostics.Debug.WriteLine($"停止采集失败,错误码:{result}");
                    System.Diagnostics.Debug.WriteLine(SN + $"停止采集失败,错误码:{result}");
                    AsyncLogHelper.Info(SN + $"停止采集失败,错误码:{result}");
                }
                _isGrabbing = false;
@@ -331,7 +458,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"停止采集失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"停止采集失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"停止采集失败:{ex.Message}");
                return false;
            }
        }
@@ -346,7 +474,8 @@
            {
                if (_camera == null || !_camera.IMV_IsOpen())
                {
                    throw new Exception("相机未打开");
                    AsyncLogHelper.Error(SN + "相机未打开");
                    throw new Exception(SN + "相机未打开");
                }
                int result = _camera.IMV_ExecuteCommandFeature("TriggerSoftware");
@@ -354,7 +483,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"软触发失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"软触发失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"软触发失败:{ex.Message}");
                return false;
            }
        }
@@ -375,7 +505,8 @@
            {
                if (_camera == null || !_camera.IMV_IsOpen())
                {
                    throw new Exception("相机未打开");
                    AsyncLogHelper.Error(SN + "相机未打开");
                    throw new Exception(SN + "相机未打开");
                }
                // 设置触发模式
@@ -383,7 +514,8 @@
                int result = _camera.IMV_SetEnumFeatureSymbol("TriggerMode", triggerMode);
                if (result != IMVDefine.IMV_OK)
                {
                    throw new Exception($"设置触发模式失败,错误码:{result}");
                    AsyncLogHelper.Error(SN + $"设置触发模式失败,错误码:{result}");
                    throw new Exception(SN + $"设置触发模式失败,错误码:{result}");
                }
                // 设置触发源
@@ -393,7 +525,8 @@
                    result = _camera.IMV_SetEnumFeatureSymbol("TriggerSource", triggerSource);
                    if (result != IMVDefine.IMV_OK)
                    {
                        throw new Exception($"设置触发源失败,错误码:{result}");
                        AsyncLogHelper.Error(SN + $"设置触发源失败,错误码:{result}");
                        throw new Exception(SN + $"设置触发源失败,错误码:{result}");
                    }
                }
@@ -401,7 +534,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"设置触发模式失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"设置触发模式失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"设置触发模式失败:{ex.Message}");
                return false;
            }
        }
@@ -421,7 +555,8 @@
            {
                if (_camera == null || !_camera.IMV_IsOpen())
                {
                    throw new Exception("相机未打开");
                    AsyncLogHelper.Error(SN + "相机未打开");
                    throw new Exception(SN + "相机未打开");
                }
                // 获取触发模式
@@ -444,7 +579,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"获取触发模式失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"获取触发模式失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"获取触发模式失败:{ex.Message}");
                return false;
            }
        }
@@ -460,7 +596,8 @@
            {
                if (_camera == null || !_camera.IMV_IsOpen())
                {
                    throw new Exception("相机未打开");
                    AsyncLogHelper.Error(SN + "相机未打开");
                    throw new Exception(SN + "相机未打开");
                }
                // 验证曝光时间范围
@@ -468,32 +605,37 @@
                int result = _camera.IMV_GetDoubleFeatureMin("ExposureTime", ref minExp);
                if (result != IMVDefine.IMV_OK)
                {
                    throw new Exception($"获取曝光时间最小值失败,错误码:{result}");
                    AsyncLogHelper.Error(SN + $"获取曝光时间最小值失败,错误码:{result}");
                    throw new Exception(SN + $"获取曝光时间最小值失败,错误码:{result}");
                }
                result = _camera.IMV_GetDoubleFeatureMax("ExposureTime", ref maxExp);
                if (result != IMVDefine.IMV_OK)
                {
                    throw new Exception($"获取曝光时间最大值失败,错误码:{result}");
                    AsyncLogHelper.Error(SN + $"获取曝光时间最大值失败,错误码:{result}");
                    throw new Exception(SN + $"获取曝光时间最大值失败,错误码:{result}");
                }
                if (value < minExp || value > maxExp)
                {
                    throw new Exception($"曝光时间超出范围,有效范围:{minExp} - {maxExp}");
                    AsyncLogHelper.Error(SN + $"曝光时间超出范围,有效范围:{minExp} - {maxExp}");
                    throw new Exception(SN + $"曝光时间超出范围,有效范围:{minExp} - {maxExp}");
                }
                // 设置曝光时间
                result = _camera.IMV_SetDoubleFeatureValue("ExposureTime", value);
                if (result != IMVDefine.IMV_OK)
                {
                    throw new Exception($"设置曝光时间失败,错误码:{result}");
                    AsyncLogHelper.Error(SN + $"设置曝光时间失败,错误码:{result}");
                    throw new Exception(SN + $"设置曝光时间失败,错误码:{result}");
                }
                return true;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"设置曝光时间失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"设置曝光时间失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"设置曝光时间失败:{ex.Message}");
                return false;
            }
        }
@@ -511,7 +653,8 @@
            {
                if (_camera == null || !_camera.IMV_IsOpen())
                {
                    throw new Exception("相机未打开");
                    AsyncLogHelper.Error(SN + "相机未打开");
                    throw new Exception(SN + "相机未打开");
                }
                int result = _camera.IMV_GetDoubleFeatureValue("ExposureTime", ref value);
@@ -519,7 +662,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"获取曝光时间失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"获取曝光时间失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"获取曝光时间失败:{ex.Message}");
                return false;
            }
        }
@@ -535,7 +679,8 @@
            {
                if (_camera == null || !_camera.IMV_IsOpen())
                {
                    throw new Exception("相机未打开");
                    AsyncLogHelper.Error(SN + "相机未打开");
                    throw new Exception(SN + "相机未打开");
                }
                string gainFeature = _camera.IMV_FeatureIsValid("Gain") ? "Gain" : "GainRaw";
@@ -545,13 +690,15 @@
                int result = _camera.IMV_GetDoubleFeatureMin(gainFeature, ref minGain);
                if (result != IMVDefine.IMV_OK)
                {
                    throw new Exception($"获取增益最小值失败,错误码:{result}");
                    AsyncLogHelper.Error(SN + $"获取增益最小值失败,错误码:{result}");
                    throw new Exception(SN + $"获取增益最小值失败,错误码:{result}");
                }
                result = _camera.IMV_GetDoubleFeatureMax(gainFeature, ref maxGain);
                if (result != IMVDefine.IMV_OK)
                {
                    throw new Exception($"获取增益最大值失败,错误码:{result}");
                    AsyncLogHelper.Error(SN + $"获取增益最大值失败,错误码:{result}");
                    throw new Exception(SN + $"获取增益最大值失败,错误码:{result}");
                }
                if (gain < minGain) gain = minGain;
@@ -561,14 +708,16 @@
                result = _camera.IMV_SetDoubleFeatureValue(gainFeature, gain);
                if (result != IMVDefine.IMV_OK)
                {
                    throw new Exception($"设置增益失败,错误码:{result}");
                    AsyncLogHelper.Error(SN + $"设置增益失败,错误码:{result}");
                    throw new Exception(SN + $"设置增益失败,错误码:{result}");
                }
                return true;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"设置增益失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"设置增益失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"设置增益失败:{ex.Message}");
                return false;
            }
        }
@@ -586,7 +735,8 @@
            {
                if (_camera == null || !_camera.IMV_IsOpen())
                {
                    throw new Exception("相机未打开");
                    AsyncLogHelper.Error(SN + "相机未打开");
                    throw new Exception(SN + "相机未打开");
                }
                string gainFeature = _camera.IMV_FeatureIsValid("Gain") ? "Gain" : "GainRaw";
@@ -595,7 +745,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"获取增益失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"获取增益失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"获取增益失败:{ex.Message}");
                return false;
            }
        }
@@ -619,7 +770,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"设置触发极性失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"设置触发极性失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"设置触发极性失败:{ex.Message}");
                return false;
            }
        }
@@ -647,7 +799,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"获取触发极性失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"获取触发极性失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"获取触发极性失败:{ex.Message}");
                return false;
            }
        }
@@ -671,7 +824,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"设置触发滤波失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"设置触发滤波失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"设置触发滤波失败:{ex.Message}");
                return false;
            }
        }
@@ -695,7 +849,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"获取触发滤波失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"获取触发滤波失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"获取触发滤波失败:{ex.Message}");
                return false;
            }
        }
@@ -718,7 +873,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"设置触发延时失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"设置触发延时失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"设置触发延时失败:{ex.Message}");
                return false;
            }
        }
@@ -742,7 +898,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"获取触发延时失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"获取触发延时失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"获取触发延时失败:{ex.Message}");
                return false;
            }
        }
@@ -767,7 +924,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"设置信号线模式失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"设置信号线模式失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"设置信号线模式失败:{ex.Message}");
                return false;
            }
        }
@@ -791,7 +949,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"设置信号线状态失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"设置信号线状态失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"设置信号线状态失败:{ex.Message}");
                return false;
            }
        }
@@ -820,7 +979,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"获取信号线状态失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"获取信号线状态失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"获取信号线状态失败:{ex.Message}");
                return false;
            }
        }
@@ -843,7 +1003,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"自动白平衡失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"自动白平衡失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"自动白平衡失败:{ex.Message}");
                return false;
            }
        }
@@ -880,14 +1041,16 @@
                        if ((uint)result != 0x80000001 && result != -119 && result != -102) // 超时错误代码
                        {
                            // 非超时错误
                            System.Diagnostics.Debug.WriteLine($"获取图像帧失败,错误码:{result}");
                            System.Diagnostics.Debug.WriteLine(SN + $"获取图像帧失败,错误码:{result}");
                            AsyncLogHelper.Error(SN + $"获取图像帧失败,错误码:{result}");
                            Thread.Sleep(10); // 出错时稍作等待
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine($"采集线程异常:{ex.Message}");
                    System.Diagnostics.Debug.WriteLine(SN + $"采集线程异常:{ex.Message}");
                    AsyncLogHelper.Error(SN + $"采集线程异常:{ex.Message}");
                    Thread.Sleep(10);
                }
@@ -918,7 +1081,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"处理图像帧失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"处理图像帧失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"处理图像帧失败:{ex.Message}");
            }
            finally
            {
@@ -957,7 +1121,8 @@
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"图像格式转换失败:{ex.Message}");
                System.Diagnostics.Debug.WriteLine(SN + $"图像格式转换失败:{ex.Message}");
                AsyncLogHelper.Error(SN + $"图像格式转换失败:{ex.Message}");
                return null;
            }
        }