|
楼主 |
发表于 2007-11-27 15:52:35
|
显示全部楼层
我的代码是下面这样写的,但打出来的完全不对!帮我看看哪里错了!
- #include <stdio.h>
- #include <string.h>
- #define FONTFILE "./Eng24x24.dat"
- void puts24(int x,int y,char s_to_deplay,unsigned char colour)
- {
- register int i,j,k;
- unsigned char buf[24*3+4];
- unsigned long location = 24*3*(s_to_deplay);
- FILE* fp = NULL;
- unsigned long tmp = 0;
- fp = fopen(FONTFILE, "rb");
- if (NULL == fp)
- {
- printf("fail to open font file\n");
- return ;
- }
- fseek(fp, location, SEEK_SET);
- memset(buf, 0, sizeof(buf));
- fread(buf, 24*3, 1, fp);
- for(i=0;i<24;i++)
- {
- tmp = (buf[i])|(buf[i+1]<<8)|(buf[i+2]<<16);
- //tmp = (buf[i]<<16)|(buf[i+1]<<8)|(buf[i+2]);
- #if 0
- printf("tmp[%x]\n", tmp);
- #else
- for(j=0;j<24;j++)
- {
- if(((tmp>>(23-j))&0x1)!=0)
- {
- putchar('*');
- }
- else
- {
- putchar(' ');
- }
- }
- putchar('\n');
- #endif
- }
- fclose(fp);
- return ;
- }
- int main(int argc, char *argv[])
- {
- char input = argv[1][0];
- //printf("inut val is %x\n", input);
- puts24(0,0,input,0);
- return 0;
- }
复制代码 |
|