用C语言编程实现对显示缓冲区进行读/写操作,在屏幕上显示住址、电话和姓名。
想了很久 尝试了一些,还是没有结果.那位帮帮忙.汉字在16X16点阵下显示.
谢谢大家的提醒和关注哈.我写了一个.要求在turbo c下编译,但是显示还是有点问题。不能在其他上面做.
大家帮忙看看那里有问题,帮我该下,不盛感激!!!!
#include<graphics.h>
#include <stdio.h>
#include <conio.h>
const char* Hz16Path ="C:\JMSOFT\CLanguage\tc";
const char * HzStr = "湖北";
FILE *handle;
int OpenHz(const char *Hz16Path)
{
int O_RDONLY ,O_BINARY;
return (handle=open(Hz16Path,O_RDONLY | O_BINARY));
}
int Wrt16Hz(int x, int y,int z,int color,char *p)
/*在(x,y)用color颜色显示汉字串p,汉字之间的空格数为z */
{
unsigned int i,c1,c2,f=0; /*x,y:write at (x,y);*/
int rec,i1,i2,i3; /*z:space between;*/
long offset; /*color:txt color*/
char by[32]; /*p:HZ str*/
if( handle<0 ) return -1;
while((i=*p++)!=0)
{
if(i>0xa0)
if(f==0){
c1=(i-0xa0)&0x07f;
f=1;
}
else{
c2=(i-0xa0)&0x07f;
f=0;
rec=(c1-1)*94+c2-1;
offset=rec*32L;
lseek(handle,offset,SEEK_SET);
read(handle,by,32);
for(i1=0;i1<16;i1++)
for(i2=0;i2<2;i2++)
for(i3=0;i3<8;i3++)
if(GetBit(by[i1*2+i2],7-i3))
putpixel(x+i2*8+i3,y+i1,color);
x=x+z+16;
}
}
return(x);
}
int GetBit(unsigned char c,int n) /*取得汉字的点阵数据*/
{
return((c>>n)&1);
}
void CloseHz(void) /*汉字显示结束,应该关闭字库文件*/
{
close( handle );
}
int main()
{
int gr=DETECT,gm;
initgraph(&gr,&gm,"C:\JMSOFT\CLanguage\tc");
OpenHz( Hz16Path );
Wrt16Hz(200,200,10,RED,HzStr);
CloseHz();
getch();
closegraph();
return 0;
}
#include<graphics.h>
#include <stdio.h>
#include <conio.h>
#include <FCNTL.H>
const char* Hz16Path ="HZK16"; /*16X16汉字库在当前目录.*/
char * HzStr = "湖北";
int handle; /*open()返回的不是FILE*类型,而是int*/
int OpenHz(const char *Hz16Path)
{
/*int O_RDONLY ,O_BINARY;在FCNTL.H有定义*/
return (handle=open(Hz16Path,O_RDONLY | O_BINARY));
}
int Wrt16Hz(int x, int y,int z,int color,char *p)
/*在(x,y)用color颜色显示汉字串p,汉字之间的空格数为z */
{
unsigned int i,c1,c2,f=0; /*x,y:write at (x,y);*/
int rec,i1,i2,i3; /*z:space between;*/
long offset; /*color:txt color*/
char by[32]; /*p:HZ str*/
if( handle<0 ) return -1;
while((i=*p++)!=0)
{
if(i>0xa0)
if(f==0){
c1=(i-0xa0)&0x07f;
f=1;
}
else{
c2=(i-0xa0)&0x07f;
f=0;
rec=(c1-1)*94+c2-1;
offset=rec*32L;
lseek(handle,offset,SEEK_SET);
read(handle,by,32);
for(i1=0;i1<16;i1++)
for(i2=0;i2<2;i2++)
for(i3=0;i3<8;i3++)
if(GetBit(by[i1*2+i2],7-i3))
putpixel(x+i2*8+i3,y+i1,color);
x=x+z+16;
}
}
return(x);
}
int GetBit(unsigned char c,int n) /*取得汉字的点阵数据*/
{
return((c>>n)&1);
}
void CloseHz(void) /*汉字显示结束,应该关闭字库文件*/
{
close( handle );
}
int main()
{
int gr=DETECT,gm;
initgraph(&gr,&gm,"C:\JMSOFT\CLanguage\tc");
OpenHz( Hz16Path );
Wrt16Hz(200,200,10,4,HzStr);
CloseHz();
getch();
closegraph();
return 0;
}