From 902834c0d8826e8b883c7fa23d1d3a14f3cbdef3 Mon Sep 17 00:00:00 2001 From: ZouJin Date: Fri, 1 Sep 2023 00:05:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20#141=20=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=88=86=E8=BE=A8=E7=8E=87=E5=A4=B1=E6=95=88=20?= =?UTF-8?q?=E5=92=8C=20=E4=BF=AE=E5=A4=8D=E5=A4=A7=E9=95=BF=E5=8A=A8?= =?UTF-8?q?=E7=94=BB=E5=AF=BC=E8=87=B4=E8=BF=87=E9=95=BF=E5=88=86=E8=BE=A8?= =?UTF-8?q?=E7=8E=87=E5=AF=BC=E8=87=B4=E5=8F=AF=E8=83=BD=E7=9A=84=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Core/Graph/PNGAnimation.cs | 20 ++++++++++++++------ VPet-Simulator.Windows/MainWindow.xaml.cs | 6 ++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/VPet-Simulator.Core/Graph/PNGAnimation.cs b/VPet-Simulator.Core/Graph/PNGAnimation.cs index b998eb0..5a7694c 100644 --- a/VPet-Simulator.Core/Graph/PNGAnimation.cs +++ b/VPet-Simulator.Core/Graph/PNGAnimation.cs @@ -164,17 +164,21 @@ namespace VPet_Simulator.Core } public double Width; + /// + /// 最大同时加载数 + /// + public static int MaxLoadNumber = 20; private void startup(string path, FileInfo[] paths) { - while (NowLoading > 20) + while (NowLoading > MaxLoadNumber) { Thread.Sleep(100); } Interlocked.Increment(ref NowLoading); //新方法:加载大图片 //生成大文件加载非常慢,先看看有没有缓存能用 - Path = System.IO.Path.Combine(GraphCore.CachePath, $"{GraphCore.Resolution}_{Sub.GetHashCode(path)}_{paths.Length}.png"); + Path = System.IO.Path.Combine(GraphCore.CachePath, $"{GraphCore.Resolution}_{Math.Abs(Sub.GetHashCode(path))}_{paths.Length}.png"); Width = 500 * (paths.Length + 1); if (!File.Exists(Path) && !((List)GraphCore.CommConfig["Cache"]).Contains(path)) { @@ -185,10 +189,15 @@ namespace VPet_Simulator.Core var img = System.Drawing.Image.FromFile(firstImage.FullName); w = img.Width; h = img.Height; - if (w > 1000) + if (w > GraphCore.Resolution) { - w = 1000; - h = (int)(h * (1000 / (double)img.Width)); + w = GraphCore.Resolution; + h = (int)(h * (GraphCore.Resolution / (double)img.Width)); + } + if(paths.Length * w >= 6000) + {//修复大长动画导致过长分辨率导致可能的报错 + w = 6000 / paths.Length; + h = (int)(h * (GraphCore.Resolution / (double)img.Width)); } using (Bitmap joinedBitmap = new Bitmap(w * paths.Length, h)) @@ -204,7 +213,6 @@ namespace VPet_Simulator.Core graph.DrawImage(img, w * i, 0, w, h); } }); - if (!File.Exists(Path)) joinedBitmap.Save(Path); } diff --git a/VPet-Simulator.Windows/MainWindow.xaml.cs b/VPet-Simulator.Windows/MainWindow.xaml.cs index cc09ade..7558fea 100644 --- a/VPet-Simulator.Windows/MainWindow.xaml.cs +++ b/VPet-Simulator.Windows/MainWindow.xaml.cs @@ -43,6 +43,12 @@ namespace VPet_Simulator.Windows public System.Timers.Timer AutoSaveTimer = new System.Timers.Timer(); public MainWindow() { +#if X64 + PNGAnimation.MaxLoadNumber = 1000; +#else + PNGAnimation.MaxLoadNumber = 20; +#endif + LocalizeCore.StoreTranslation = true; CultureInfo.CurrentCulture = new CultureInfo(CultureInfo.CurrentCulture.Name); CultureInfo.CurrentCulture.NumberFormat = new CultureInfo("en-US").NumberFormat;