Fix textual palettes not accepting to be filled

A weird case of off-by-one error
This commit is contained in:
ISSOtm
2024-07-26 16:42:56 +02:00
committed by Sylvie
parent d8aceaea4a
commit 8e60d1f0b8
4 changed files with 44 additions and 4 deletions

View File

@@ -371,13 +371,13 @@ static void parseGPLFile(std::filebuf &file) {
return;
}
++nbColors;
if (nbColors < maxNbColors) {
if (nbColors % options.nbColorsPerPal == 1) {
if (nbColors % options.nbColorsPerPal == 0) {
options.palSpec.emplace_back();
}
options.palSpec.back()[nbColors % options.nbColorsPerPal] = *color;
}
++nbColors;
}
if (nbColors > maxNbColors) {
@@ -419,13 +419,13 @@ static void parseHEXFile(std::filebuf &file) {
Rgba color =
Rgba(toHex(line[0], line[1]), toHex(line[2], line[3]), toHex(line[4], line[5]), 0xFF);
++nbColors;
if (nbColors < maxNbColors) {
if (nbColors % options.nbColorsPerPal == 1) {
if (nbColors % options.nbColorsPerPal == 0) {
options.palSpec.emplace_back();
}
options.palSpec.back()[nbColors % options.nbColorsPerPal] = color;
}
++nbColors;
}
if (nbColors > maxNbColors) {