{
SDL_Surface * rawbmp;
SDL_PixelFormat * fmt;
+ FILE * ostream;
char filename[] = "test.bmp";
+ char outname[] = "test.gfx";
rawbmp = SDL_LoadBMP(filename);
if (!rawbmp) {
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);
} */
+ 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);