mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-05 00:39:50 +00:00
Save color palette in RGB .ase files (fix #487)
This commit is contained in:
parent
a609f121fa
commit
c3d36d3598
@ -1,5 +1,5 @@
|
|||||||
ASE Files (.ASE) Format description
|
ASE Files (.ASE) Format description
|
||||||
Copyright (C) 2001-2013 by David Capello
|
Copyright (C) 2001-2014 by David Capello
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
1. References
|
1. References
|
||||||
@ -39,10 +39,9 @@ PIXEL Pixel format:
|
|||||||
The format is much like FLI/FLC files, but with different magic number
|
The format is much like FLI/FLC files, but with different magic number
|
||||||
and differents chunks. Also, the color depth can be 8, 16 or 32 for
|
and differents chunks. Also, the color depth can be 8, 16 or 32 for
|
||||||
Indexed, Grayscale and RGB respectively, and the images are more easy
|
Indexed, Grayscale and RGB respectively, and the images are more easy
|
||||||
to read (there aren't differences with old frames). The palette isn't
|
to read (there aren't differences with old frames). Color palettes
|
||||||
included for color depths more than 8, but when the sprite is 8 bpp,
|
are in FLI color chunks (it could be type=11 or type=4). For color
|
||||||
the palette is in a FLI color chunk (it could be type=11 or type=4).
|
depths more than 8bpp, palettes are optional. See fli.txt for details.
|
||||||
See fli.txt for details.
|
|
||||||
|
|
||||||
To read the sprite, just do this:
|
To read the sprite, just do this:
|
||||||
* Read the ASE header (section 3)
|
* Read the ASE header (section 3)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Aseprite
|
/* Aseprite
|
||||||
* Copyright (C) 2001-2013 David Capello
|
* Copyright (C) 2001-2014 David Capello
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -211,25 +211,19 @@ bool AseFormat::onLoad(FileOp* fop)
|
|||||||
|
|
||||||
/* only for 8 bpp images */
|
/* only for 8 bpp images */
|
||||||
case ASE_FILE_CHUNK_FLI_COLOR:
|
case ASE_FILE_CHUNK_FLI_COLOR:
|
||||||
case ASE_FILE_CHUNK_FLI_COLOR2:
|
case ASE_FILE_CHUNK_FLI_COLOR2: {
|
||||||
/* fop_error(fop, "Color chunk\n"); */
|
Palette* prev_pal = sprite->getPalette(frame);
|
||||||
|
Palette* pal =
|
||||||
|
chunk_type == ASE_FILE_CHUNK_FLI_COLOR ?
|
||||||
|
ase_file_read_color_chunk(f, sprite, frame):
|
||||||
|
ase_file_read_color2_chunk(f, sprite, frame);
|
||||||
|
|
||||||
if (sprite->pixelFormat() == IMAGE_INDEXED) {
|
if (prev_pal->countDiff(pal, NULL, NULL) > 0)
|
||||||
Palette* prev_pal = sprite->getPalette(frame);
|
sprite->setPalette(pal, true);
|
||||||
Palette* pal =
|
|
||||||
chunk_type == ASE_FILE_CHUNK_FLI_COLOR ?
|
|
||||||
ase_file_read_color_chunk(f, sprite, frame):
|
|
||||||
ase_file_read_color2_chunk(f, sprite, frame);
|
|
||||||
|
|
||||||
if (prev_pal->countDiff(pal, NULL, NULL) > 0) {
|
delete pal;
|
||||||
sprite->setPalette(pal, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete pal;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
fop_error(fop, "Warning: was found a color chunk in non-8bpp file\n");
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ASE_FILE_CHUNK_LAYER: {
|
case ASE_FILE_CHUNK_LAYER: {
|
||||||
/* fop_error(fop, "Layer chunk\n"); */
|
/* fop_error(fop, "Layer chunk\n"); */
|
||||||
@ -320,9 +314,8 @@ bool AseFormat::onSave(FileOp* fop)
|
|||||||
// Frame duration
|
// Frame duration
|
||||||
frame_header.duration = sprite->getFrameDuration(frame);
|
frame_header.duration = sprite->getFrameDuration(frame);
|
||||||
|
|
||||||
// The sprite is indexed and the palette changes? (or is the first frame)
|
// is the first frame or did the palette change?
|
||||||
if (sprite->pixelFormat() == IMAGE_INDEXED &&
|
if ((frame == 0 ||
|
||||||
(frame == 0 ||
|
|
||||||
sprite->getPalette(frame.previous())->countDiff(sprite->getPalette(frame), NULL, NULL) > 0)) {
|
sprite->getPalette(frame.previous())->countDiff(sprite->getPalette(frame), NULL, NULL) > 0)) {
|
||||||
// Write the color chunk
|
// Write the color chunk
|
||||||
ase_file_write_color2_chunk(f, &frame_header, sprite->getPalette(frame));
|
ase_file_write_color2_chunk(f, &frame_header, sprite->getPalette(frame));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user