diff options
author | red031000 <rubenru09@aol.com> | 2020-06-07 15:57:16 +0100 |
---|---|---|
committer | red031000 <rubenru09@aol.com> | 2020-06-07 15:57:16 +0100 |
commit | cc67cafa094351a033f295d054380acc63fddd78 (patch) | |
tree | bdfae5029031b07a4c525a7378fe546f05de79b3 | |
parent | cc5a1e59920fe0ed975af40aa49b7870832323af (diff) |
fix bitdepth
-rw-r--r-- | tools/nitrogfx/gfx.c | 3 | ||||
-rw-r--r-- | tools/nitrogfx/gfx.h | 1 | ||||
-rw-r--r-- | tools/nitrogfx/jasc_pal.c | 7 |
3 files changed, 10 insertions, 1 deletions
diff --git a/tools/nitrogfx/gfx.c b/tools/nitrogfx/gfx.c index 25c346db..bb6ff442 100644 --- a/tools/nitrogfx/gfx.c +++ b/tools/nitrogfx/gfx.c @@ -400,7 +400,8 @@ void WriteNtrPalette(char *path, struct Palette *palette) fputc((extSize >> 24) & 0xFF, fp); //bit depth - fputc(0x03, fp); //todo figure out a way to determine bit depth + char bitDepth = palette->bitDepth == 4 ? 0x03: 0x04; + fputc(bitDepth, fp); fputc(0x00, fp); fputc(0x00, fp); fputc(0x00, fp); diff --git a/tools/nitrogfx/gfx.h b/tools/nitrogfx/gfx.h index d5241509..c563a2dc 100644 --- a/tools/nitrogfx/gfx.h +++ b/tools/nitrogfx/gfx.h @@ -15,6 +15,7 @@ struct Color { struct Palette { struct Color colors[256]; int numColors; + int bitDepth; }; struct Image { diff --git a/tools/nitrogfx/jasc_pal.c b/tools/nitrogfx/jasc_pal.c index e5ba9c3c..4f80f5d9 100644 --- a/tools/nitrogfx/jasc_pal.c +++ b/tools/nitrogfx/jasc_pal.c @@ -91,6 +91,8 @@ void ReadJascPalette(char *path, struct Palette *palette) if (palette->numColors < 1 || palette->numColors > 256) FATAL_ERROR("%d is an invalid number of colors. The number of colors must be in the range [1, 256].\n", palette->numColors); + palette->bitDepth = 4; + for (int i = 0; i < palette->numColors; i++) { ReadJascPaletteLine(fp, line); @@ -146,6 +148,11 @@ void ReadJascPalette(char *path, struct Palette *palette) palette->colors[i].red = red; palette->colors[i].green = green; palette->colors[i].blue = blue; + if (i >= 16) + { + if (red || green || blue) + palette->bitDepth = 8; + } } if (fgetc(fp) != EOF) |