From: <kw...@us...> - 2003-07-07 14:23:17
|
Update of /cvsroot/aedgui/aedGUI/tools In directory sc8-pr-cvs1:/tmp/cvs-serv1417 Added Files: font2res.cpp Log Message: added initial font2res.cpp under directory /tools a program that converts a binary file into a header like resource, removed the empty /fonts directory --- NEW FILE: font2res.cpp --- // Initial Code by Rodrigo Hernandez (Kwizatz) for aedGUI (C) 2003 #include <stdio.h> int main(int argc, char *argv[]) { unsigned char byte; int bytecount = 0; int varsize = 0; size_t filesize; if(argc!=2) { printf("\nUsage %s [font]\n",argv[0]); return -1; } FILE *infile = fopen(argv[1],"rb"); if (infile==NULL) { printf("\nThe file %s was not found or is in use by another application\n",argv[1]); return -1; } FILE *outfile = fopen("font.h","wb"); if(outfile==NULL) return -1; fseek(infile,0,SEEK_END); filesize = ftell(infile); fseek(infile,0,SEEK_SET); fprintf(outfile,"const int fontsize=0x%x;\n",filesize); fprintf(outfile,"const unsigned char font[]={"); while(!feof(infile)) { fread(&byte,1,1,infile); fprintf(outfile,"0x%x",byte); if(!feof(infile)) fprintf(outfile,","); ++varsize; ++bytecount; if(bytecount==10) { bytecount=0; fprintf(outfile,"\n"); } } fprintf(outfile,"};\n"); fclose(infile); fclose(outfile); }; |