mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 12:44:53 +00:00
Fix slice chunk on aseprite spec (fix #1663)
This commit is contained in:
parent
166cb55c97
commit
f6cbbd1e89
@ -1,6 +1,6 @@
|
|||||||
# Aseprite File Format (.ase/.aseprite) Specifications
|
# Aseprite File Format (.ase/.aseprite) Specifications
|
||||||
|
|
||||||
> Copyright (C) 2001-2017 by David Capello
|
> Copyright (C) 2001-2018 by David Capello
|
||||||
|
|
||||||
1. [References](#references)
|
1. [References](#references)
|
||||||
2. [Introduction](#introduction)
|
2. [Introduction](#introduction)
|
||||||
@ -17,6 +17,7 @@ ASE files use Intel (little-endian) byte order.
|
|||||||
* `WORD`: A 16-bit unsigned integer value
|
* `WORD`: A 16-bit unsigned integer value
|
||||||
* `SHORT`: A 16-bit signed integer value
|
* `SHORT`: A 16-bit signed integer value
|
||||||
* `DWORD`: A 32-bit unsigned 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
|
* `FIXED`: A 32-bit fixed point (16.16) value
|
||||||
* `BYTE[n]`: "n" bytes.
|
* `BYTE[n]`: "n" bytes.
|
||||||
* `STRING`:
|
* `STRING`:
|
||||||
@ -283,19 +284,19 @@ belongs to that cel, etc.
|
|||||||
+ For each slice key
|
+ For each slice key
|
||||||
DWORD Frame number (this slice is valid from
|
DWORD Frame number (this slice is valid from
|
||||||
this frame to the end of the animation)
|
this frame to the end of the animation)
|
||||||
SHORT Slice X origin coordinate in the sprite
|
LONG Slice X origin coordinate in the sprite
|
||||||
SHORT Slice Y origin coordinate in the sprite
|
LONG Slice Y origin coordinate in the sprite
|
||||||
WORD Slice width (can be 0 if this slice hidden in the
|
DWORD Slice width (can be 0 if this slice hidden in the
|
||||||
animation from the given frame)
|
animation from the given frame)
|
||||||
WORD Slice height
|
DWORD Slice height
|
||||||
+ If flags have bit 1
|
+ If flags have bit 1
|
||||||
SHORT Center X position (relative to slice bounds)
|
LONG Center X position (relative to slice bounds)
|
||||||
SHORT Center Y position
|
LONG Center Y position
|
||||||
WORD Center width
|
DWORD Center width
|
||||||
WORD Center height
|
DWORD Center height
|
||||||
+ If flags have bit 2
|
+ If flags have bit 2
|
||||||
WORD Pivot X position (relative to the slice origin)
|
LONG Pivot X position (relative to the slice origin)
|
||||||
WORD Pivot Y position (relative to the slice origin)
|
LONG Pivot Y position (relative to the slice origin)
|
||||||
|
|
||||||
### Notes
|
### Notes
|
||||||
|
|
||||||
|
@ -959,15 +959,15 @@ static void ase_file_write_slice_chunk(FILE* f, dio::AsepriteFrameHeader* frame_
|
|||||||
for (auto key : range) {
|
for (auto key : range) {
|
||||||
if (frame == fromFrame || key != oldKey) {
|
if (frame == fromFrame || key != oldKey) {
|
||||||
fputl(frame, f);
|
fputl(frame, f);
|
||||||
fputl(key ? key->bounds().x: 0, f);
|
fputl((int32_t)(key ? key->bounds().x: 0), f);
|
||||||
fputl(key ? key->bounds().y: 0, f);
|
fputl((int32_t)(key ? key->bounds().y: 0), f);
|
||||||
fputl(key ? key->bounds().w: 0, f);
|
fputl(key ? key->bounds().w: 0, f);
|
||||||
fputl(key ? key->bounds().h: 0, f);
|
fputl(key ? key->bounds().h: 0, f);
|
||||||
|
|
||||||
if (flags & ASE_SLICE_FLAG_HAS_CENTER_BOUNDS) {
|
if (flags & ASE_SLICE_FLAG_HAS_CENTER_BOUNDS) {
|
||||||
if (key && key->hasCenter()) {
|
if (key && key->hasCenter()) {
|
||||||
fputl(key->center().x, f);
|
fputl((int32_t)key->center().x, f);
|
||||||
fputl(key->center().y, f);
|
fputl((int32_t)key->center().y, f);
|
||||||
fputl(key->center().w, f);
|
fputl(key->center().w, f);
|
||||||
fputl(key->center().h, 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 (flags & ASE_SLICE_FLAG_HAS_PIVOT_POINT) {
|
||||||
if (key && key->hasPivot()) {
|
if (key && key->hasPivot()) {
|
||||||
fputl(key->pivot().x, f);
|
fputl((int32_t)key->pivot().x, f);
|
||||||
fputl(key->pivot().y, f);
|
fputl((int32_t)key->pivot().y, f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fputl(0, f);
|
fputl(0, f);
|
||||||
|
@ -836,21 +836,21 @@ doc::Slice* AsepriteDecoder::readSliceChunk(doc::Slices& slices)
|
|||||||
gfx::Rect bounds, center;
|
gfx::Rect bounds, center;
|
||||||
gfx::Point pivot = doc::SliceKey::NoPivot;
|
gfx::Point pivot = doc::SliceKey::NoPivot;
|
||||||
doc::frame_t frame = read32();
|
doc::frame_t frame = read32();
|
||||||
bounds.x = read32();
|
bounds.x = ((int32_t)read32());
|
||||||
bounds.y = read32();
|
bounds.y = ((int32_t)read32());
|
||||||
bounds.w = read32();
|
bounds.w = read32();
|
||||||
bounds.h = read32();
|
bounds.h = read32();
|
||||||
|
|
||||||
if (flags & ASE_SLICE_FLAG_HAS_CENTER_BOUNDS) {
|
if (flags & ASE_SLICE_FLAG_HAS_CENTER_BOUNDS) {
|
||||||
center.x = read32();
|
center.x = ((int32_t)read32());
|
||||||
center.y = read32();
|
center.y = ((int32_t)read32());
|
||||||
center.w = read32();
|
center.w = read32();
|
||||||
center.h = read32();
|
center.h = read32();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & ASE_SLICE_FLAG_HAS_PIVOT_POINT) {
|
if (flags & ASE_SLICE_FLAG_HAS_PIVOT_POINT) {
|
||||||
pivot.x = read32();
|
pivot.x = ((int32_t)read32());
|
||||||
pivot.y = read32();
|
pivot.y = ((int32_t)read32());
|
||||||
}
|
}
|
||||||
|
|
||||||
slice->insert(frame, doc::SliceKey(bounds, center, pivot));
|
slice->insert(frame, doc::SliceKey(bounds, center, pivot));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user