回 帖 发 新 帖 刷新版面

主题:TC3.0环境下显示汉字程序

/**TC3.0环境下显示汉字程序,请将本源文件和12*12点阵汉字库文件hzk12放在同一目录下再编译运行本文件。
*hzk12文件大小192kb,如果找不到地方下载可以向本人索要.
*作者:meteor135(流星雨) meteor@mail.biti.edu.cn, smith_135@163.com
*完成时间:2003年8月14日
*/
#include <stdio.h>//for FILE
#include <graphics.h>//for graphics
#define GRAPH_DVR_PATH "F:\\TC\\BGI" //请将此路径改为你本机环境对应的BGI路径

void get_hz(FILE* hzk_p, char incode[],char bytes[]);
void dis_hz(FILE* hzk_p, int x, int y, char code[], int color,int expandBy);
void put_hz(char *s,int x, int y, int color, int wordSpace, int lineSpace, int direction, int expandBy, int lineDes);
/**parameter @s:            pointer to the hanzi string to show
* parameter @x:            x coordinates the s start showing in screen
* parameter @y:            y coordinates the s start showing in screen
* parameter @color:        string s's color
* parameter @wordSpace:    word space
* parameter @lineSpace:    line space
* parameter @direction:    the direction at which string s to show, 0:left->right,others: up->down
* parameter @expandBy:     the word will be expanded by it as multiple.
* parameter @lineDes:      when direction is not 0, lineDes will control the string lines descending direction.
*/
void main()
{
    char *s="春眠不觉晓  处处闻啼鸟  夜来风雨声  花落知多少";
    int driver = DETECT;
    int mode = 0;
    initgraph(&driver,&mode,GRAPH_DVR_PATH);
    put_hz(s,20,130,WHITE,16,30,0,2,0);
    put_hz(s,250,230,GREEN,16,30,1,1,1);
    put_hz(s,340,230,YELLOW,16,30,1,1,-1);
    getch();
    closegraph();
}
void put_hz(char *s,int x, int y, int color, int wordSpace, int lineSpace, int direction, int expandBy,int lineDes)
{
    int x0 = x, y0 = y;
    FILE *hzk_p;
    if(!(hzk_p=fopen("hzk12","rb")))
    {
        printf("The file HZK12 does not exist! press any key to quit\n");
        return;
    }
    while(*s!=NULL)
    {
        while(*s!=NULL&&x<640-12*expandBy&&y<480-12*expandBy&&x>=0&&y>=0)
        {
            if(*s!=32)  //ignore space
                dis_hz(hzk_p,x,y,s,color,expandBy);
            if(direction == 0)
                x += wordSpace*expandBy;
            else
                y += wordSpace*expandBy;
            s+=2;
        }
        if(direction == 0)
        {
            x = x0;
            y += lineSpace*expandBy;
        }
        else
        {
            y = y0;
            x += lineDes*lineSpace*expandBy;
        }
    }
}
void get_hz(FILE* hzk_p, char incode[],char bytes[])
{
    unsigned char qh, wh;
    unsigned long offset;
    qh = incode[0] - 0xa0;
    wh = incode[1] - 0xa0;
    offset = (94*(qh-1)+(wh-1))*24L;
    fseek(hzk_p,offset,SEEK_SET);
    fread(bytes,24,1,hzk_p);
}
void dis_hz(FILE* hzk_p, int x, int y, char code[], int color, int expandBy)
{
    int i, j, m, n;
    char mat[24];
    get_hz(hzk_p,code,mat);
    for(i=0; i< 12; ++i)
    {
        for(j = 0; j < 12; ++j)
        {
            if(((128>>j%8)&mat[2*i+j/8])!=NULL)
            {
                for(m=0; m<expandBy; m ++)
                {
                    for(n=0;n<expandBy; n++)
                    {
                        putpixel(x+expandBy*j+m,y+expandBy*i+n,color);
                    }
                }
            }
        }
    }
}

回复列表 (共36个回复)

11 楼

我不知道怎么看汉字库的格式..不过我生成的那个汉字库的大小和你的不一样,估计不一样吧..能否麻烦你给我发一个汉字库(boyghost@hotmail.com)..在这先谢谢了

12 楼

已经发给你了,请查收!

13 楼

谢谢,已收到!

14 楼

楼主:
   http://go8.jaying.net/tc256/download/download.htm这个网页好象不存在了,能否麻烦你给我也发一个汉字库文件,我急用。谢谢!!
  邮箱:liouyezhuifeng@yahoo.com.cn

15 楼

是啊!我也打不开!能不能麻烦你帮忙发到我的邮箱里?
我的邮箱:cwllsl@sina.com

16 楼

已收到,谢谢!
还有一个问题要请教:这个和TC的汉化补丁有区别吗?我下载了一个汉化补丁,但好象只能在98下运行,我装的是XP。另外你发给我的文件,在XP下好象也无法打开
这是怎么回事?

17 楼

已收到,谢谢!
还有一个问题要请教:这个和TC的汉化补丁有区别吗?我下载了一个汉化补丁,但好象只能在98下运行,我装的是XP。另外你发给我的文件,在XP下好象也无法打开
这是怎么回事?

18 楼

不好意思,可能是昨天由于网速太慢了,不知道已经发出去,所以误发了两次,请各位见量!!

19 楼

楼主也给我发一个吧!
  谢谢了!    hyw25802002@yahoo.com.cn
 

20 楼

楼主,也给我发一份吧,谢谢了!!
ayay2003@tom.com

我来回复

您尚未登录,请登录后再回复。点此登录或注册