Add palette checks for png sprites.
This commit is contained in:
@@ -45,13 +45,16 @@ namespace OpenRA.Mods.Common.SpriteLoaders
|
||||
public bool TryParseSprite(Stream s, out ISpriteFrame[] frames, out TypeDictionary metadata)
|
||||
{
|
||||
metadata = null;
|
||||
frames = null;
|
||||
if (!Png.Verify(s))
|
||||
{
|
||||
frames = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
var png = new Png(s);
|
||||
|
||||
// Only supports paletted images
|
||||
if (png.Palette == null)
|
||||
return false;
|
||||
|
||||
List<Rectangle> frameRegions;
|
||||
List<float2> frameOffsets;
|
||||
|
||||
|
||||
@@ -35,6 +35,9 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
var dest = inputFiles[0].Split('-').First() + ".shp";
|
||||
|
||||
var frames = inputFiles.Select(a => new Png(File.OpenRead(a))).ToList();
|
||||
if (frames.Any(f => f.Palette == null))
|
||||
throw new InvalidOperationException("All frames must be paletted");
|
||||
|
||||
var size = new Size(frames[0].Width, frames[0].Height);
|
||||
if (frames.Any(f => f.Width != size.Width || f.Height != size.Height))
|
||||
throw new InvalidOperationException("All frames must be the same size");
|
||||
|
||||
Reference in New Issue
Block a user