| 321 | } |
| 322 | |
| 323 | static void |
| 324 | build_bmptile(pixel(*pixels)[TILE_X]) |
| 325 | { |
| 326 | int cur_x, cur_y, cur_color, apply_color; |
| 327 | int x, y; |
| 328 | uchar *c; |
| 329 | |
| 330 | for (cur_y = 0; cur_y < TILE_Y; cur_y++) { |
| 331 | for (cur_x = 0; cur_x < TILE_X; cur_x++) { |
| 332 | for (cur_color = 0; cur_color < num_colors; cur_color++) { |
| 333 | if (ColorMap[CM_RED][cur_color] == pixels[cur_y][cur_x].r |
| 334 | && ColorMap[CM_GREEN][cur_color] == pixels[cur_y][cur_x].g |
| 335 | && ColorMap[CM_BLUE][cur_color] == pixels[cur_y][cur_x].b) |
| 336 | break; |
| 337 | } |
| 338 | if (cur_color >= num_colors) |
| 339 | Fprintf(stderr, "color not in colormap! (tile #%d)\n", |
| 340 | tiles_counted); |
| 341 | y = (max_y - 1) - (cur_y + yoffset); |
| 342 | apply_color = cur_color; |
| 343 | x = cur_x + xoffset; |
| 344 | c = &newbmp->packtile + ((y * max_x) + x); |
| 345 | *c = (uchar) apply_color; |
| 346 | } |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | static int |
| 351 | set_tilefile_path(const char *fdir, const char *fname, char *buf, size_t sz) |