修复关联失败问题 继续优化读单

This commit is contained in:
wule committed 2026-10-18 17:18:30 +08:00
1 parent a786ba6ce9
commit 7df2cc0957
5 files changed
+135 -55

No files matched your search

+8 -7
View File
@@ -5,6 +5,7 @@ using System.Drawing.Imaging;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using System.Windows.Media.Imaging;
@@ -388,11 +389,6 @@ namespace AllBase
public static BitmapImage LoadBitmipImageFromUrl(string url, int? width = 0, int? height = 0)
{
BitmapImage bitmap = new BitmapImage();
if (width != null && height != null)
{
bitmap.DecodePixelWidth = 100;
bitmap.DecodePixelHeight = 100;
}
try
{
@@ -403,11 +399,16 @@ namespace AllBase
{
stream.Position = 0; // 重置流的位置到开始处
bitmap.BeginInit();
bitmap.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
if (width != null && height != null)
{
bitmap.DecodePixelWidth = width.Value;
bitmap.DecodePixelHeight = height.Value;
}
bitmap.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
bitmap.CacheOption = BitmapCacheOption.OnLoad; // 或者使用 BitmapCacheOption.OnLoad 以减少内存使用
bitmap.UriSource = null; // 清除可能的旧UriSource,防止缓存问题
bitmap.StreamSource = stream;
bitmap.EndInit();
bitmap.EndInit();
bitmap.Freeze(); // 防止后续更改,提高性能
}
}