?? hzcall2.c
字號:
//********************************************
//文件名:HZCALL2.C
//功能:1. 函數(shù)outhz()判斷是否為漢字,若是則將
//漢字傳給函數(shù)disp()處理,若是字符則輸出
// 2. 函數(shù)disp()調(diào)用畫點(diǎn)函數(shù)輸出漢字
//********************************************
#include<GRAPHICS.H> //1.
#include"hzku2.h" //2.包含字庫頭文件
int disp(int,int,unsigned char, //3.被調(diào)用函數(shù)聲明
unsigned char,int); //4.
int outhz(int x,int y,char *p,int color) //5.
{ //6.
int oldcolor; //7.
oldcolor=getcolor(); //8.取得當(dāng)前顏色
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.檢查最大坐標(biāo)
(y+16-1)>getmaxy()) //18.
return 0; //19.
disp(x,y,*p,*(p+1),color); //20.若是漢字調(diào)用顯示函數(shù)
p+=2; //21.將指針指向下一個漢字
x+=16+2; //22.設(shè)置水平坐標(biāo)
moveto(x,y); //23.移動顯示位置
} //24.
else //25.若不是漢字
{ //26.
char q[2]; //27.字符處理
moveto(x,y); //28.
*q=*p; //29.
*(q+1)='\0'; //30.補(bǔ)結(jié)束符
settextstyle(DEFAULT_FONT,HORIZ_DIR,1); //31.設(shè)置字符顯示屬性
outtextxy(x,y+4,q); //32.輸出字符串(實(shí)為字符)
x+=8+1; p++; //33.
} //34.
} //35.
setcolor(oldcolor); //36.設(shè)置顏色
return 1; //37.
} //38.
//39.
int disp(int left,int top,unsigned char byte1, //40.顯示漢字函數(shù)
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.取機(jī)內(nèi)碼兩字節(jié)16位值
for(m=0;sb[m]!=0;m++) //50.
{ //51.
if(k==sb[m]) //52.與漢字特征值比較
break; //53.若相等則結(jié)束比較
} //54.
for(i=0,y=top;i<31;i+=2,y++) //55.字節(jié)循環(huán)
for(mark=0x80,j=0;mark>0;mark=mark>>1,j++)//56.位循環(huán)
{ //57.
if((buff[m][i]&mark)!=0) //58.若為1(偶字節(jié))
putpixel(left+j,y,color); //59.顯示一個亮點(diǎn)
if((buff[m][i+1]&mark)!=0) //60.若為1(奇字節(jié))
putpixel(left+j+8,y,color); //61.顯示一個亮點(diǎn)
} //62.
} //63.
return 1; //64.
} //65.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -