home *** CD-ROM | disk | FTP | other *** search
- #include <fstream.h>
- #include <stdlib.h>
- #include <fastgraf.h>
- #include <dir.h>
- #include <string.h>
- #include "pcx.h"
- #include "utils.h"
-
- static ofstream cfile;
-
- // ------ hotspot table ( add to this for new cursors )
- static struct hs {
- char *fn;
- int x, y;
- } HotSpots[] = {
- { "LF", 0, 1 },
- { "RT", 15, 1 },
- { "DN", 14, 15 },
- { "UP", 14, 0 },
- { "UL", 0, 0 },
- { "UR", 15, 0 },
- { "LR", 15, 15 },
- { "LL", 0, 15 },
- { "CN", 7, 0 },
- { "DE", 0, 0 },
- { 0, 0, 0 }
- };
-
- void bld_cursors(char *fname)
- {
- static pcx_header header;
- fg_pcxhead(fname,(char*)&header);
- int w = header.width+1-header.x;
- int h = header.height+1-header.y;
- if (w != 16 && h != 16) {
- fg_setmode(3);
- cerr << "Invalid ht/wd: " << h << '/' << w;
- exit(1);
- }
- fg_setcolor(0);
- fg_rect(0,319,0,239);
- fg_move(0,0);
- fg_showpcx(fname,2);
-
- long size=fg_imagesiz(w,h);
- if (size != 256) {
- fg_setmode(3);
- cerr << "Invalid # of colors: " << size;
- exit(1);
- }
-
- static char curs[512];
-
- for (int i = 0; i < 16; i++) {
- fg_move(0,i);
- fg_getimage(curs+256+i*16,16,1);
- }
-
- for (i = 0; i < 256; i++)
- curs[i] = (curs[256+i]) ? 0 : 0xff;
-
- char arname[MAXFILE];
- _splitpath(fname, 0, 0, arname, 0);
-
-
- // --- base hotspot value on 1st 2 characters of file name
- hs *hsp = HotSpots;
- while (hsp->fn != 0) {
- if (strncmp(hsp->fn, arname, 2) == 0)
- break;
- hsp++;
- }
- int x = hsp->x;
- int y = hsp->y;
-
- cfile << "\nchar " << arname << "[] = { "
- << x << ", " << y << ", // hotspot x/y";
-
- for (i = 0; i < 512; i++) {
- if ((i % 16) == 0)
- cfile << "\n\t";
- cfile.width(3);
- cfile.fill(' ');
- cfile << dec << (curs[i] & 0xff);
- if (i < 511)
- cfile << ',';
- }
- cfile << "\n};";
- }
-
- int main(int argc, char *argv[])
- {
- if (argc > 2) {
- cfile.open(argv[1]);
- fg_setmode(22);
- parse_cmdline(argc-2, argv+2, bld_cursors);
- fg_setmode(3);
- return 0;
- }
- return 1;
- }
-
-