diff --git a/Windows/CS/Framework4.0/Toprie/Toprie/Camera.cs b/Windows/CS/Framework4.0/Toprie/Toprie/Camera.cs index 6cf64a9..4d52668 100644 --- a/Windows/CS/Framework4.0/Toprie/Toprie/Camera.cs +++ b/Windows/CS/Framework4.0/Toprie/Toprie/Camera.cs @@ -811,18 +811,7 @@ namespace JoyD.Windows.CS.Toprie // 清除InfoImage和显示标志 lock (_infoImageLock) { - if (_infoImage != null) - { - try - { - _infoImage.Dispose(); - _infoImage = null; - } - catch (Exception ex) - { - Console.WriteLine($"释放InfoImage资源异常: {ex.Message}"); - } - } + _infoImage = null; // 直接设为null,不需要Dispose } _isDisplayingInfo = false; @@ -877,21 +866,13 @@ namespace JoyD.Windows.CS.Toprie // 在InfoImage中显示连接断开信息 lock (_infoImageLock) { - // 释放之前的InfoImage资源 - if (_infoImage != null) + // 如果_infoImage为null,则创建新对象 + if (_infoImage == null) { - try - { - _infoImage.Dispose(); - } - catch (Exception ex) - { - Console.WriteLine($"释放InfoImage资源异常: {ex.Message}"); - } + _infoImage = new Bitmap(BUFFER_WIDTH, BUFFER_HEIGHT); } - // 创建新的InfoImage并绘制断开连接字样 - _infoImage = new Bitmap(BUFFER_WIDTH, BUFFER_HEIGHT); + // 直接在现有InfoImage上重绘,不需要Dispose using (Graphics g = Graphics.FromImage(_infoImage)) { // 设置半透明背景 @@ -936,21 +917,13 @@ namespace JoyD.Windows.CS.Toprie // 在InfoImage中显示正在重连信息 lock (_infoImageLock) { - // 释放之前的InfoImage资源 - if (_infoImage != null) + // 如果_infoImage为null,则创建新对象 + if (_infoImage == null) { - try - { - _infoImage.Dispose(); - } - catch (Exception ex) - { - Console.WriteLine($"释放InfoImage资源异常: {ex.Message}"); - } + _infoImage = new Bitmap(BUFFER_WIDTH, BUFFER_HEIGHT); } - // 创建新的InfoImage并绘制正在重连字样 - _infoImage = new Bitmap(BUFFER_WIDTH, BUFFER_HEIGHT); + // 直接在现有InfoImage上重绘,不需要Dispose using (Graphics g = Graphics.FromImage(_infoImage)) { // 设置半透明背景