Add support for more chunks per frame

This issue appeared for first time here:
https://community.aseprite.org/t/1762/4
This commit is contained in:
David Capello 2018-08-06 18:05:04 -03:00
parent d13806ac23
commit 9e65ff9ad8
4 changed files with 17 additions and 6 deletions

View File

@ -82,9 +82,14 @@ header of 16 bytes:
DWORD Bytes in this frame
WORD Magic number (always 0xF1FA)
WORD Number of "chunks" in this frame
WORD Old field which specifies the number of "chunks"
in this frame. If this value is 0xFFFF, we might
have more chunks to read in this frame
(so we have to use the new field)
WORD Frame duration (in milliseconds)
BYTE[6] For future (set to zero)
BYTE[2] For future (set to zero)
DWORD New field which specifies the number of "chunks"
in this frame (if this is 0, use the old field)
Then each chunk format is:

View File

@ -416,9 +416,10 @@ static void ase_file_write_frame_header(FILE* f, dio::AsepriteFrameHeader* frame
fputl(frame_header->size, f);
fputw(frame_header->magic, f);
fputw(frame_header->chunks, f);
fputw(frame_header->chunks < 0xFFFF ? frame_header->chunks: 0xFFFF, f);
fputw(frame_header->duration, f);
ase_file_write_padding(f, 6);
ase_file_write_padding(f, 2);
fputl(frame_header->chunks, f);
fseek(f, end, SEEK_SET);
}

View File

@ -68,7 +68,7 @@ struct AsepriteHeader {
struct AsepriteFrameHeader {
uint32_t size;
uint16_t magic;
uint16_t chunks;
uint32_t chunks;
uint16_t duration;
};

View File

@ -268,7 +268,12 @@ void AsepriteDecoder::readFrameHeader(AsepriteFrameHeader* frame_header)
frame_header->magic = read16();
frame_header->chunks = read16();
frame_header->duration = read16();
readPadding(6);
readPadding(2);
uint32_t nchunks = read32();
if (frame_header->chunks == 0xFFFF &&
frame_header->chunks < nchunks)
frame_header->chunks = nchunks;
}
void AsepriteDecoder::readPadding(int bytes)