From 5dfcc3e9d073d7aa3e316a0e5518a0dfb7b957d5 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Fri, 10 Apr 2015 18:34:06 +0100 Subject: [PATCH] Convert custom map previews that are not using PixelFormat.Format32bppArgb. --- OpenRA.Game/Map/Map.cs | 9 +++++++++ OpenRA.Game/Map/MapPreview.cs | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index 782c7fdbf8..b61ed70706 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -12,6 +12,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Drawing; +using System.Drawing.Imaging; using System.IO; using System.Linq; using System.Security.Cryptography; @@ -391,8 +392,16 @@ namespace OpenRA DefaultSubCell = (SubCell)Game.ModData.Manifest.SubCellDefaultIndex; if (Container.Exists("map.png")) + { using (var dataStream = Container.GetContent("map.png")) CustomPreview = new Bitmap(dataStream); + if (CustomPreview.PixelFormat != PixelFormat.Format32bppArgb) + { + var original = CustomPreview; + CustomPreview = original.Clone(original.Bounds(), PixelFormat.Format32bppArgb); + original.Dispose(); + } + } PostInit(); diff --git a/OpenRA.Game/Map/MapPreview.cs b/OpenRA.Game/Map/MapPreview.cs index fb843d1eaa..ab3bbd3402 100644 --- a/OpenRA.Game/Map/MapPreview.cs +++ b/OpenRA.Game/Map/MapPreview.cs @@ -13,6 +13,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Drawing; +using System.Drawing.Imaging; using System.IO; using System.Linq; using System.Net; @@ -155,6 +156,12 @@ namespace OpenRA SpawnPoints = spawns; CustomPreview = new Bitmap(new MemoryStream(Convert.FromBase64String(r.minimap))); + if (CustomPreview.PixelFormat != PixelFormat.Format32bppArgb) + { + var original = CustomPreview; + CustomPreview = original.Clone(original.Bounds(), PixelFormat.Format32bppArgb); + original.Dispose(); + } } catch (Exception) { }