From 765b359840159febaf4a90ae89c207da10a363aa Mon Sep 17 00:00:00 2001 From: ZouJin Date: Sun, 7 Apr 2024 16:04:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E5=A4=B9=E5=B1=82=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=86=85=E5=AD=98=E5=9B=9E=E6=94=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Core/Graph/FoodAnimation.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/VPet-Simulator.Core/Graph/FoodAnimation.cs b/VPet-Simulator.Core/Graph/FoodAnimation.cs index 32b265e..f720be7 100644 --- a/VPet-Simulator.Core/Graph/FoodAnimation.cs +++ b/VPet-Simulator.Core/Graph/FoodAnimation.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Media; +using System.Windows.Media.Imaging; using static VPet_Simulator.Core.IGraph; namespace VPet_Simulator.Core @@ -280,7 +281,14 @@ namespace VPet_Simulator.Core var BL = GraphCore.FindGraph(Back_Lay, GraphInfo.Animat, GraphInfo.ModeType); var t1 = FL?.Run(FoodGrid.Front); var t2 = BL?.Run(FoodGrid.Back); - FoodGrid.Food.Source = image; + if (FoodGrid.Food.Source != image) + { + if (FoodGrid.Food.Source is BitmapImage bitmapImage) + {//内存回收 + bitmapImage.StreamSource?.Dispose(); + } + FoodGrid.Food.Source = image; + } t1?.Start(); t2?.Start(); Task.Run(() => Animations[0].Run(FoodGrid.Food, EndAction));