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) {

1
test/gfx/full_hex.flags Normal file
View File

@@ -0,0 +1 @@
-c hex:full_hex.hex

39
test/gfx/full_hex.hex Normal file
View File

@@ -0,0 +1,39 @@
e77300
008cce
634218
000000
efd600
5ad639
008cce
000000
efd600
ef9c8c
5ab5ef
008cce
efd600
5ad639
39217b
000000
efd600
00ef63
5ab5ef
316331
efd600
adadc6
ef9c8c
5ab5ef
e77300
634218
39217b
000000
5ad639
316331
39217b
000000

BIN
test/gfx/full_hex.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 881 B