apng loading works

This commit is contained in:
Adam D. Ruppe 2019-03-26 22:49:50 -04:00
parent 85b6a93e47
commit 66a86be0b7
2 changed files with 12 additions and 12 deletions

21
apng.d
View File

@ -57,6 +57,7 @@ class ApngFrame {
auto height = frameControlChunk.height;
auto bytesPerLine = bytesPerLineOfPng(parent.header.depth, parent.header.type, width);
bytesPerLine--; // removing filter byte from this calculation since we handle separtely
int idataIdx;
ubyte[] idata;
@ -79,11 +80,7 @@ class ApngFrame {
this.data = idata;
}
// then need to uncompress it
// and unfilter it...
// and then convert it to the right format.
MemoryImage frameData;
//MemoryImage frameData;
}
class ApngAnimation {
@ -109,16 +106,16 @@ enum APNG_BLEND_OP : byte {
OVER = 1
}
void readApng(in ubyte[] data) {
ApngAnimation readApng(in ubyte[] data) {
auto png = readPng(data);
auto header = PngHeader.fromChunk(png.chunks[0]);
Color[] palette;
if(header.type == 3) {
palette = fetchPalette(png);
}
auto obj = new ApngAnimation();
if(header.type == 3) {
obj.palette = fetchPalette(png);
}
bool seenIdat = false;
bool seenFctl = false;
@ -227,11 +224,13 @@ void readApng(in ubyte[] data) {
expectedSequenceNumber++;
// and the rest of it is a datastream...
obj.frames[frameNumber - 1].compressedDatastream ~= chunk.payload;
obj.frames[frameNumber - 1].compressedDatastream ~= chunk.payload[offset .. $];
break;
default:
// ignore
}
}
return obj;
}

3
png.d
View File

@ -231,7 +231,7 @@ void convertPngData(ubyte type, ubyte depth, const(ubyte)[] data, int width, uby
break;
default: assert(0);
}
assert(data.length == 0, "not all consumed, wtf ");// ~ to!string(h));
assert(data.length == 0, "not all consumed, wtf " ~ to!string(data));
}
/*
@ -1482,6 +1482,7 @@ struct LazyPngFile(LazyPngChunksProvider)
}
// FIXME: doesn't handle interlacing... I think
// note it returns the length including the filter byte!!
@nogc @safe pure nothrow
int bytesPerLineOfPng(ubyte depth, ubyte type, uint width) {
immutable bitsPerChannel = depth;