HZK16.H
上传用户:phillytech
上传日期:2007-01-07
资源大小:561k
文件大小:1k
- ////////////////////////////////////
- // 西文状态下实现汉字输出 (hzk16)//
- // hzk16.h 郁明 F_FIRE@990.net //
- ////////////////////////////////////
- #include <stdlib.h>
- #include <stdio.h>
- #include <graphics.h>
- #include <string.h>
- #define HZK16 "hzk16"
- int test(unsigned int a,int k)
- {
- a<<=(k-1);
- if(a&0x80)
- return (1);
- else
- return (0);
- }
- void hz16(int X,int Y,char *zw,int c)
- { int n=0;
- while(n!=strlen(zw)){ register int i,j;
- register int xx=0;
- register int yy=0;
- FILE *fp;char *wm;long num;
- fp=fopen(HZK16,"rb++");
- if(fp==NULL){/*打开hzk16字库错误*/exit(0);}
- if((zw[n]&0x80)==0)
- {
- num=188+zw[n]-33;
- fseek(fp,(32)*num,0);
- fread(wm,32,1,fp);
- fclose(fp);
- for(i=0;i<32;i++)
- {for(j=1;j<=8;j++)
- if(test(wm[i],j)==0)
- xx++;
- else{putpixel((xx)+X,Y+yy,c);xx++;}
- if((i+1)%2==0){xx=0;yy++;}
- }X=X+16;n=n+1;
- }else{
- zw[n]=zw[n]&0x7f;
- zw[n+1]=zw[n+1]&0x7f;
- zw[n]=zw[n]-0x20;
- zw[n+1]=zw[n+1]-0x20;
- num=(zw[n]-1)*94+(zw[n+1]-1);
- fseek(fp,(32)*num,0);
- fread(wm,32,1,fp);
- fclose(fp);
- for(i=0;i<32;i++)
- {for(j=1;j<=8;j++)
- if(test(wm[i],j)==0)
- xx++;
- else{putpixel((xx)+X,Y+yy,c);xx++;}
- if((i+1)%2==0){xx=0;yy++;}
- }X=X+16;n=n+2;
- }}
- }