projects
/
swan-dev
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e5de2e9
)
tools: output stream for .gfx 4bpp file
author
Robin Krens
<robin@robinkrens.nl>
Sun, 12 Jun 2022 14:00:37 +0000
(16:00 +0200)
committer
Robin Krens
<robin@robinkrens.nl>
Sun, 12 Jun 2022 14:00:37 +0000
(16:00 +0200)
tools/bmp2tiles/bmp2tiles.c
patch
|
blob
|
history
diff --git
a/tools/bmp2tiles/bmp2tiles.c
b/tools/bmp2tiles/bmp2tiles.c
index
42a8805
..
25ea7d5
100644
(file)
--- a/
tools/bmp2tiles/bmp2tiles.c
+++ b/
tools/bmp2tiles/bmp2tiles.c
@@
-56,7
+56,9
@@
int main(void)
{
SDL_Surface * rawbmp;
SDL_PixelFormat * fmt;
{
SDL_Surface * rawbmp;
SDL_PixelFormat * fmt;
+ FILE * ostream;
char filename[] = "test.bmp";
char filename[] = "test.bmp";
+ char outname[] = "test.gfx";
rawbmp = SDL_LoadBMP(filename);
if (!rawbmp) {
rawbmp = SDL_LoadBMP(filename);
if (!rawbmp) {
@@
-71,14
+73,21
@@
int main(void)
SDL_UnlockSurface(rawbmp);
unsigned char *tile_buf = malloc(sizeof(unsigned char) * TILE_SZ);
SDL_UnlockSurface(rawbmp);
unsigned char *tile_buf = malloc(sizeof(unsigned char) * TILE_SZ);
-
- generate_4bpp_tile_packed(tile_buf, rawbmp->userdata, 64);
/* if (rawbmp->format->BitsPerPixel != 24) {
fprintf(stderr, "format %d not supported\n", rawbmp->format->BitsPerPixel);
exit(EXIT_FAILURE);
} */
/* if (rawbmp->format->BitsPerPixel != 24) {
fprintf(stderr, "format %d not supported\n", rawbmp->format->BitsPerPixel);
exit(EXIT_FAILURE);
} */
+ ostream = fopen(outname, "w");
+ if (!ostream) {
+ fprintf(stderr, "can not open file for writing!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ generate_4bpp_tile_packed(tile_buf, rawbmp->userdata, 64);
+ int ret = fwrite(tile_buf, sizeof(unsigned char), 32, ostream);
+ printf("written: %d\n", ret);
SDL_FreeSurface(rawbmp);
SDL_FreeSurface(rawbmp);