mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-27 12:20:58 +00:00
Don't write color2 chunk for files with more than 256 colors (fix #4322)
We were incorrectly saving a wrong number of entries for palettes with more than 256 colors in color2 chunk, anyway it doesn't make sense to use this chunks as it doesn't support more than 256 colors. So we removed it for this case. We've also removed the palette chunk for cases where it's not required at all, e.g. when we have less than 256 colors and doesn't have alpha channel, it makes sense to use the color2 chunk as it's smaller in the output file.
This commit is contained in:
parent
0d5075ff93
commit
10dda30a15
@ -126,9 +126,12 @@ at least.
|
||||
|
||||
### Old palette chunk (0x0004)
|
||||
|
||||
Ignore this chunk if you find the new palette chunk (0x2019) Aseprite
|
||||
v1.1 saves both chunks 0x0004 and 0x2019 just for backward
|
||||
compatibility.
|
||||
Ignore this chunk if you find the new palette chunk (0x2019). Aseprite
|
||||
v1.1 saves both chunks (0x0004 and 0x2019) just for backward
|
||||
compatibility. Aseprite v1.3.5 writes this chunk if the palette
|
||||
doesn't have alpha channel and contains 256 colors or less (because
|
||||
this chunk is smaller), in other case the new palette chunk (0x2019)
|
||||
will be used (and the old one is not saved anymore).
|
||||
|
||||
WORD Number of packets
|
||||
+ For each packet
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2024 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -355,7 +355,7 @@ bool AseFormat::onSave(FileOp* fop)
|
||||
|
||||
bool require_new_palette_chunk = false;
|
||||
for (Palette* pal : sprite->getPalettes()) {
|
||||
if (pal->size() != 256 || pal->hasAlpha()) {
|
||||
if (pal->size() > 256 || pal->hasAlpha()) {
|
||||
require_new_palette_chunk = true;
|
||||
break;
|
||||
}
|
||||
@ -393,9 +393,12 @@ bool AseFormat::onSave(FileOp* fop)
|
||||
ase_file_write_palette_chunk(f, &frame_header,
|
||||
pal, palFrom, palTo);
|
||||
}
|
||||
|
||||
// Write color chunk for backward compatibility only
|
||||
ase_file_write_color2_chunk(f, &frame_header, pal);
|
||||
else {
|
||||
// Use old color chunk only when the palette has 256 or less
|
||||
// colors, and we don't need the alpha channel (as this chunk
|
||||
// is smaller than the new palette chunk).
|
||||
ase_file_write_color2_chunk(f, &frame_header, pal);
|
||||
}
|
||||
}
|
||||
|
||||
// Write extra chunks in the first frame
|
||||
@ -676,6 +679,7 @@ static void ase_file_write_color2_chunk(FILE* f, dio::AsepriteFrameHeader* frame
|
||||
|
||||
// First packet
|
||||
fputc(0, f); // skip 0 colors
|
||||
ASSERT(pal->size() <= 256); // For >256 we use the palette chunk
|
||||
fputc(pal->size() == 256 ? 0: pal->size(), f); // number of colors
|
||||
for (c=0; c<pal->size(); c++) {
|
||||
color = pal->getEntry(c);
|
||||
|
Loading…
Reference in New Issue
Block a user