Fix slice chunk on aseprite spec (fix #1663)

This commit is contained in:
David Capello 2018-02-14 09:27:09 -03:00
parent 166cb55c97
commit f6cbbd1e89
3 changed files with 24 additions and 23 deletions

View File

@ -1,6 +1,6 @@
# Aseprite File Format (.ase/.aseprite) Specifications
> Copyright (C) 2001-2017 by David Capello
> Copyright (C) 2001-2018 by David Capello
1. [References](#references)
2. [Introduction](#introduction)
@ -17,6 +17,7 @@ ASE files use Intel (little-endian) byte order.
* `WORD`: A 16-bit unsigned integer value
* `SHORT`: A 16-bit signed integer value
* `DWORD`: A 32-bit unsigned integer value
* `LONG`: A 32-bit signed integer value
* `FIXED`: A 32-bit fixed point (16.16) value
* `BYTE[n]`: "n" bytes.
* `STRING`:
@ -283,19 +284,19 @@ belongs to that cel, etc.
+ For each slice key
DWORD Frame number (this slice is valid from
this frame to the end of the animation)
SHORT Slice X origin coordinate in the sprite
SHORT Slice Y origin coordinate in the sprite
WORD Slice width (can be 0 if this slice hidden in the
LONG Slice X origin coordinate in the sprite
LONG Slice Y origin coordinate in the sprite
DWORD Slice width (can be 0 if this slice hidden in the
animation from the given frame)
WORD Slice height
DWORD Slice height
+ If flags have bit 1
SHORT Center X position (relative to slice bounds)
SHORT Center Y position
WORD Center width
WORD Center height
LONG Center X position (relative to slice bounds)
LONG Center Y position
DWORD Center width
DWORD Center height
+ If flags have bit 2
WORD Pivot X position (relative to the slice origin)
WORD Pivot Y position (relative to the slice origin)
LONG Pivot X position (relative to the slice origin)
LONG Pivot Y position (relative to the slice origin)
### Notes

View File

@ -959,15 +959,15 @@ static void ase_file_write_slice_chunk(FILE* f, dio::AsepriteFrameHeader* frame_
for (auto key : range) {
if (frame == fromFrame || key != oldKey) {
fputl(frame, f);
fputl(key ? key->bounds().x: 0, f);
fputl(key ? key->bounds().y: 0, f);
fputl((int32_t)(key ? key->bounds().x: 0), f);
fputl((int32_t)(key ? key->bounds().y: 0), f);
fputl(key ? key->bounds().w: 0, f);
fputl(key ? key->bounds().h: 0, f);
if (flags & ASE_SLICE_FLAG_HAS_CENTER_BOUNDS) {
if (key && key->hasCenter()) {
fputl(key->center().x, f);
fputl(key->center().y, f);
fputl((int32_t)key->center().x, f);
fputl((int32_t)key->center().y, f);
fputl(key->center().w, f);
fputl(key->center().h, f);
}
@ -981,8 +981,8 @@ static void ase_file_write_slice_chunk(FILE* f, dio::AsepriteFrameHeader* frame_
if (flags & ASE_SLICE_FLAG_HAS_PIVOT_POINT) {
if (key && key->hasPivot()) {
fputl(key->pivot().x, f);
fputl(key->pivot().y, f);
fputl((int32_t)key->pivot().x, f);
fputl((int32_t)key->pivot().y, f);
}
else {
fputl(0, f);

View File

@ -836,21 +836,21 @@ doc::Slice* AsepriteDecoder::readSliceChunk(doc::Slices& slices)
gfx::Rect bounds, center;
gfx::Point pivot = doc::SliceKey::NoPivot;
doc::frame_t frame = read32();
bounds.x = read32();
bounds.y = read32();
bounds.x = ((int32_t)read32());
bounds.y = ((int32_t)read32());
bounds.w = read32();
bounds.h = read32();
if (flags & ASE_SLICE_FLAG_HAS_CENTER_BOUNDS) {
center.x = read32();
center.y = read32();
center.x = ((int32_t)read32());
center.y = ((int32_t)read32());
center.w = read32();
center.h = read32();
}
if (flags & ASE_SLICE_FLAG_HAS_PIVOT_POINT) {
pivot.x = read32();
pivot.y = read32();
pivot.x = ((int32_t)read32());
pivot.y = ((int32_t)read32());
}
slice->insert(frame, doc::SliceKey(bounds, center, pivot));