Merge pull request #3575 from pchote/r8reader

Native R8 support for sequences
This commit is contained in:
Matthias Mailänder
2013-07-17 08:27:15 -07:00
7 changed files with 154 additions and 192 deletions

View File

@@ -51,9 +51,10 @@ namespace OpenRA.Graphics
this.allocateSheet = allocateSheet;
}
public Sprite Add(byte[] src, Size size)
public Sprite Add(byte[] src, Size size) { return Add(src, size, float2.Zero); }
public Sprite Add(byte[] src, Size size, float2 spriteOffset)
{
var rect = Allocate(size);
var rect = Allocate(size, spriteOffset);
Util.FastCopyIntoChannel(rect, src);
current.CommitData();
return rect;

View File

@@ -8,6 +8,7 @@
*/
#endregion
using System.Drawing;
using System.IO;
using System.Linq;
using OpenRA.FileFormats;
@@ -29,6 +30,13 @@ namespace OpenRA.Graphics
Sprite[] LoadSprites(string filename)
{
// TODO: Cleanly abstract file type detection
if (filename.ToLower().EndsWith("r8"))
{
var r8 = new R8Reader(FileSystem.Open(filename));
return r8.Select(a => SheetBuilder.Add(a.Image, a.Size, a.Offset)).ToArray();
}
BinaryReader reader = new BinaryReader(FileSystem.OpenWithExts(filename, exts));
var ImageCount = reader.ReadUInt16();