From 57ff1ea4069938a3004c47ffe7d3bc296cbbadf6 Mon Sep 17 00:00:00 2001 From: cyf Date: Fri, 3 Jul 2026 14:45:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E7=95=8C=E9=9D=A2=E5=B7=A6=E4=BE=A7?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 插件库/Lskj.Util/ImageHelper.cs | 16 +++++----------- 插件库/Lskj.Util/PubUtil.cs | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/插件库/Lskj.Util/ImageHelper.cs b/插件库/Lskj.Util/ImageHelper.cs index f31a754..9412bcd 100644 --- a/插件库/Lskj.Util/ImageHelper.cs +++ b/插件库/Lskj.Util/ImageHelper.cs @@ -36,10 +36,9 @@ namespace Lskj.Util { if (bytes == null) return null; using (System.IO.MemoryStream ms = new System.IO.MemoryStream(bytes)) + using (System.Drawing.Image sourceImage = System.Drawing.Image.FromStream(ms)) { - System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms); - ms.Flush(); - return returnImage; + return new Bitmap(sourceImage); } } catch (Exception) @@ -56,14 +55,9 @@ namespace Lskj.Util { try { - FileStream fs = File.OpenRead(path); //OpenRead - int filelength = 0; - filelength = (int)fs.Length; //获得文件长度 - Byte[] image = new Byte[filelength]; //建立一个字节数组 - fs.Read(image, 0, filelength); //按字节流读取 - System.Drawing.Image result = System.Drawing.Image.FromStream(fs); - fs.Close(); - return result; + if (string.IsNullOrWhiteSpace(path) || !File.Exists(path)) return null; + byte[] image = File.ReadAllBytes(path); + return ReadImage(image); } catch (Exception) { diff --git a/插件库/Lskj.Util/PubUtil.cs b/插件库/Lskj.Util/PubUtil.cs index eca0daf..5c604d9 100644 --- a/插件库/Lskj.Util/PubUtil.cs +++ b/插件库/Lskj.Util/PubUtil.cs @@ -203,6 +203,21 @@ namespace Lskj.Util { get { return BitMapPath + "Main/Module/"; } } + /// + /// 主界面左侧树图标路径 + /// + public static string MainTreeviewImagePath + { + get + { + string path = BitMapPath + "Main\\MainTreeview\\"; + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + return path; + } + } public static string MesItemImage { get { return BitMapPath + "MesItem/"; }