Convert custom map previews that are not using PixelFormat.Format32bppArgb.

This commit is contained in:
RoosterDragon
2015-04-10 18:34:06 +01:00
parent 6e14d96815
commit 5dfcc3e9d0
2 changed files with 16 additions and 0 deletions

View File

@@ -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();

View File

@@ -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) { }