projects
/
swan-dev
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b3db8c3
)
tools: bmp2tiles better warning and error handling
author
Robin Krens
<robin@robinkrens.nl>
Mon, 13 Jun 2022 20:30:24 +0000
(22:30 +0200)
committer
Robin Krens
<robin@robinkrens.nl>
Mon, 13 Jun 2022 20:30:24 +0000
(22:30 +0200)
tools/bmp2tiles/bmp2tiles.c
patch
|
blob
|
history
diff --git
a/tools/bmp2tiles/bmp2tiles.c
b/tools/bmp2tiles/bmp2tiles.c
index
c64c252
..
abc8576
100644
(file)
--- a/
tools/bmp2tiles/bmp2tiles.c
+++ b/
tools/bmp2tiles/bmp2tiles.c
@@
-37,12
+37,12
@@
int set_info(swan_gfx_t * gfx, SDL_Surface * img)
gfx->bpp = img->format->BitsPerPixel;
if (gfx->bpp != 8) {
gfx->bpp = img->format->BitsPerPixel;
if (gfx->bpp != 8) {
- fprintf(stderr, "
warning
: %d bpp format detected\n", img->format->BitsPerPixel);
+ fprintf(stderr, "
error
: %d bpp format detected\n", img->format->BitsPerPixel);
return -1;
}
if (gfx->width % 8 | gfx->height % 8) {
return -1;
}
if (gfx->width % 8 | gfx->height % 8) {
- fprintf(stderr, "
warning
: image not multiple of 16x16 tiles\n \
+ fprintf(stderr, "
error
: image not multiple of 16x16 tiles\n \
width: %d\theight: %d\n", gfx->width, gfx->height);
return -1;
}
width: %d\theight: %d\n", gfx->width, gfx->height);
return -1;
}
@@
-68,6
+68,8
@@
void generate_4bpp_tile(unsigned char *buf, swan_gfx_t * gfx,
for (int i = 0; i < TILE_SZ; i+=4) {
for (int j = 0; j < 4; ++j) {
if (packed) { /* packed format */
for (int i = 0; i < TILE_SZ; i+=4) {
for (int j = 0; j < 4; ++j) {
if (packed) { /* packed format */
+ if (ptr[0] >= 8 || ptr[1] >= 8)
+ fprintf(stdout, "warning: too many colors detected\n");
gfx->outpal[ptr[0]] = (gfx->palette[ptr[0]].r >> 4) << 8 |
(gfx->palette[ptr[0]].g >> 4) << 4 |
gfx->palette[ptr[0]].b >> 4;
gfx->outpal[ptr[0]] = (gfx->palette[ptr[0]].r >> 4) << 8 |
(gfx->palette[ptr[0]].g >> 4) << 4 |
gfx->palette[ptr[0]].b >> 4;
@@
-76,6
+78,8
@@
void generate_4bpp_tile(unsigned char *buf, swan_gfx_t * gfx,
ptr += 2;
} else { /* planar format */
for (int x = 0; x < 8; ++x) {
ptr += 2;
} else { /* planar format */
for (int x = 0; x < 8; ++x) {
+ if (ptr[x] >= 8)
+ fprintf(stdout, "warning: too many colors detected\n");
buf[i + j] = ptr[x] << j;
}
}
buf[i + j] = ptr[x] << j;
}
}