added Aseprite deflate with MiniZ

This commit is contained in:
Noel Berry 2020-05-27 19:51:50 -07:00
parent 8faeeb98f0
commit 01a4f60a63
2 changed files with 11 additions and 10 deletions

View File

@ -85,7 +85,7 @@ namespace Strawberry
Input.[Friend]Init(gamepadLimit); Input.[Friend]Init(gamepadLimit);
Sprites = new Dictionary<String, Sprite>(); Sprites = new Dictionary<String, Sprite>();
//LoadSprites(); LoadSprites();
BuildTypeLists(); BuildTypeLists();
} }

View File

@ -223,6 +223,7 @@ namespace Strawberry
width = WORD(); width = WORD();
height = WORD(); height = WORD();
// TODO: allocating the entire RGBA data may cause a stack overflow if the image is big enough?
var count = width * height * (int)mode; var count = width * height * (int)mode;
if (count > temp.Count) if (count > temp.Count)
temp = scope:: uint8[count]; temp = scope:: uint8[count];
@ -235,17 +236,17 @@ namespace Strawberry
// DEFLATE // DEFLATE
else else
{ {
//TODO: Figure this out to enable aseprite loading // TODO: allocating the entire deflated image might cause stack overflow if the image is big enough?
// get the source buffer
var source = scope::uint8[chunkEnd - stream.Position];
Runtime.FatalError("Decompression not yet implemented."); // TODO: Is there some way to read more than one byte at a time from stream?
for (int n = 0; n < source.Count; n ++)
source[n] = stream.Read<uint8>();
/* // decompress into the temp buffer
Noel's C#: var length = temp.Count;
SEEK(2); MiniZ.Uncompress(&temp[0], ref length, &source[0], source.Count);
using var deflate = new DeflateStream(reader.BaseStream, CompressionMode.Decompress, true);
deflate.Read(temp, 0, count);
*/
} }
// get pixel data // get pixel data