www.pudn.com > TP333.3_S886.rar > HZCALL.C


//******************************************** 
//文件名:HZCALL.C 
//功能:1. 函数outhz()判断是否为汉字,若是则将 
//汉字传给函数disp()处理,若是字符则输出 
//      2. 函数disp()调用画点函数输出汉字 
//******************************************** 
#include                           //1. 
#include"hzku.h"                               //2.包含字库头文件 
int disp(int,int,unsigned char,                //3.被调用函数声明 
         unsigned char,int);                   //4. 
int outhz(int x,int y,char *p,int color)       //5. 
{                                              //6. 
  int oldcolor;                                //7. 
  oldcolor=getcolor();                         //8.取得当前颜色 
  setcolor(color);                             //9. 
  while(*p)                                    //10. 
  {                                            //11. 
    if(((unsigned char)*p>=0xa1&&              //12.判断是否为汉字 
      (unsigned char)*p<=0xfe)&&               //13. 
      ((unsigned char)*(p+1)>=0xa1&&           //14. 
      (unsigned char)*(p+1)<=0xfe))            //15. 
    {                                          //16. 
      if((x+16-1)>getmaxx()||                  //17.检查最大坐标 
         (y+16-1)>getmaxy())                   //18. 
        return 0;                              //19. 
      disp(x,y,*p,*(p+1),color);               //20.若是汉字调用显示函数 
      p+=2;                                    //21.将指针指向下一个汉字 
      x+=16+2;                                 //22.设置水平坐标 
      moveto(x,y);                             //23.移动显示位置 
    }                                          //24. 
    else                                       //25.若不是汉字 
    {                                          //26. 
      char q[2];                               //27.字符处理 
      moveto(x,y);                             //28. 
      *q=*p;                                   //29. 
      *(q+1)='\0';                             //30.补结束符 
      settextstyle(DEFAULT_FONT,HORIZ_DIR,1);  //31.设置字符显示属性 
      outtextxy(x,y+4,q);                      //32.输出字符串(实为字符) 
      x+=8+1;  p++;                            //33. 
    }                                          //34. 
  }                                            //35. 
  setcolor(oldcolor);                          //36.设置颜色 
  return 1;                                    //37. 
}                                              //38. 
                                               //39. 
int disp(int left,int top,unsigned char byte1, //40.显示汉字函数 
         unsigned char byte2,int color)        //41. 
{                                              //42. 
  unsigned char mark;                          //43. 
  unsigned k;                                  //44. 
  int y,i,j,m;                                 //45. 
  if((byte1>=0xa1&&byte1<=0xfe)&&              //46.检查是否为汉字 
    (byte2>=0xa1&&byte2<=0xfe))                //47. 
  {                                            //48. 
    k=byte1+byte2*256;                         //49.取机内码两字节16位值 
    for(m=0;sb[m]!=0;m++)                      //50. 
    {                                          //51. 
      if(k==sb[m])                             //52.与汉字特征值比较 
        break;                                 //53.若相等则结束比较 
    }                                          //54. 
    for(i=0,y=top;i<31;i+=2,y++)               //55.字节循环 
      for(mark=0x80,j=0;mark>0;mark=mark>>1,j++)//56.位循环 
      {                                        //57. 
        if((buff[m][i]&mark)!=0)               //58.若为1(偶字节) 
          putpixel(left+j,y,color);            //59.显示一个亮点 
        if((buff[m][i+1]&mark)!=0)             //60.若为1(奇字节) 
          putpixel(left+j+8,y,color);          //61.显示一个亮点 
      }                                        //62. 
  }                                            //63. 
  return 1;                                    //64. 
}                                              //65.