请教各位大侠, 我想要将一个数字或者是汉字,  在一块液晶板上显示出来,  但是这首先要得到这个汉字的16*16 的字模数据,要是一个数字呢则是8*8不知道各位有什么好办法没有,  或者是将原理告诉一下。谢谢先!!!!!

解决方案 »

  1.   

    以HZK16文件为例,分析取得汉字字模的方法。
      HZK16文件是按照GB 2312-80标准,也就是通常所说的国标码或区位码的标准排列的。国标码分为 94 个区(Section),每个区 94 个位(Position),所以也称为区位码。其中01~09 区为符号、数字区,16~87 区为汉字区。而 10~15 区、88~94 区是空白区域。
      如何取得汉字的区位码呢?在计算机处理汉字和ASCII字符时,使每个ASCII字符占用1个字节,而一个汉字占用两个字节,其值称为汉字的内码。其中第一个字节的值为区号加上32(20H),第二个字节的值为位号加上32(20H)。为了与ASCII字符区别开,表示汉字的两个字节的最高位都是1,也就是两个字节的值都又加上了128(80H)。这样,通过汉字的内码,就可以计算出汉字的区位码。
      具体算式如下:
      qh=c1-32-128=c1-160    wh=c2-32-128=c2-160
      或   
      qh=c1-0xa0    wh=c2-0xa0
      qh,wh为汉字的区号和位号,c1,c2为汉字的第一字节和第二字节。
      根据区号和位号可以得到汉字字模在文件中的位置:
      location=(94*(qh-1)+(wh-1))*一个点阵字模的字节数。
      那么一个点阵字模究竟占用多少字节数呢?我们来分析一下汉字字模的具体排列方式。
      例如下图中显示的“汉”字,使用16×16点阵。字模中每一点使用一个二进制位(Bit)表示,如果是1,则说明此处有点,若是0,则说明没有。这样,一个16×16点阵的汉字总共需要16*16/8=32个字节表示。字模的表示顺序为:先从左到右,再从上到下,也就是先画左上方的8个点,再是右上方的8个点,然后是第二行左边8个点,右边8个点,依此类推,画满16×16个点。  
     
     
      对于其它点阵字库文件,则也是使用类似的方法进行显示。例如HZK12,但是HZK12文件的格式有些特别,如果你将它的字模当作12*12位计算的话,根本无法正常显示汉字。因为字库设计者为了使用的方便,字模每行的位数均补齐为8的整数倍,于是实际该字库的位长度是16*12,每个字模大小为24字节,虽然每行都多出了4位,但这4位都是0(不显示),并不影响显示效果。 还有UCDOS下的HZK24S(宋体)、HZK24K(楷体)或HZK24H(黑体)这些打印字库文件,每个字模占用24*24/8=72字节,不过这类大字模汉字库为了打印的方便,将字模都放倒了,所以在显示时要注意把横纵方向颠倒过来就可以了。
      这样我们就完全清楚了如何得到汉字的点阵字模,这样就可以在程序中随意的显示汉字了。
      如果在程序中使用的汉字数目不多,也可以不必总是在程序里带上几百K的字库文件,也许你的程序才只有几十K。这样可以事先将所需要显示的汉字字模提取出来,放在另一个文件里,按照自己的顺序读取文件就可以了。
      

  2.   

    字库
    http://www.laogu.com/download/hzk16.zip
      

  3.   

    网上有不少取字模代码,用C写的,不是很难,弄一个字库文件(UCDOS带的那个就行),然后把国标码转成区位码,根据区位码到字库文件中读字模,16x16字模数据应该是32个字节。有点忘了...
      

  4.   

    请问kaguo如何取将汉字转换成汉字的内码,应该不可能要求用户去查表对照吧,有没有什么计算公式或,谢谢!
      

  5.   

    请问kaguo如何取将汉字转换成汉字的内码,应该不可能要求用户去查表对照吧,有没有什么计算公式或,谢谢!
    //////////////////////////////////////////////////////
    你的汉字是怎么保存的?自己设计的代码吗?难道不是
      

  6.   

    我是调用字库HZK16。DAT里面的字,比如停字的区号和位号分别是45、03要如何打开HZK16。DAT去把里面的那32个字节的字模数据取出来
      

  7.   

    /* LSEEK.C: This program first opens a file named LSEEK.C.
     * It then uses _lseek to find the beginning of the file,
     * to find the current position in the file, and to find
     * the end of the file.
     */#include <io.h>
    #include <fcntl.h>
    #include <stdlib.h>
    #include <stdio.h>void main( void )
    {
       int fh;
       long pos;               /* Position of file pointer */
       char buffer[10];   fh = _open( "lseek.c", _O_RDONLY );   /* Seek the beginning of the file: */
       pos = _lseek( fh, 0L, SEEK_SET );
       if( pos == -1L )
          perror( "_lseek to beginning failed" );
       else
          printf( "Position for beginning of file seek = %ld\n", pos );   /* Move file pointer a little */
        _read( fh, buffer, 10 );   /* Find current position: */
       pos = _lseek( fh, 0L, SEEK_CUR );
       if( pos == -1L )
          perror( "_lseek to current position failed" );
       else
          printf( "Position for current position seek = %ld\n", pos );   /* Set the end of the file: */
       pos = _lseek( fh, 0L, SEEK_END );
       if( pos == -1L )
          perror( "_lseek to end failed" );
       else
          printf( "Position for end of file seek = %ld\n", pos );   _close( fh );
    }
      

  8.   

    void main( void )
    {
       int fh;
       long pos;               /* Position of file pointer */
       char buffer[32];
       char str[]="停";
       long location;
       long qh,wh;   fh = _open( "HZK16.DAT", _O_RDONLY );   // 汉字的区号 这里是“停”字
       qh=str[0]-0xa0;
       // 汉字的位号 这里是“停”字
       wh=str[1]-0xa0;   // location=(94*(qh-1)+(wh-1))*一个点阵字模的字节数。
       location=(94*(qh-1)+(wh-1))*32;   // 移动指针到location
       pos = _lseek( fh, location, SEEK_SET);   // 读数据
       _read( fh, buffer, 32);   _close( fh );
    }
      

  9.   

    谢谢ASZ()的程序,你写的程序用的是C,不用呢,我现在想用的是DELPHI程序编写,我对DELPHI的打开文件,以及一些想应的指针不太熟悉,不知道可否有知道用DELPHI编写的人,请告知,不过仍然要谢谢ASZ()!
      

  10.   

    以下是我写的一段程序,我显示出来的数据是空的,不知道什么原因,我在EDIT中得出来的数据是对了,分别是4503,4506,请各位帮忙看看
    unit text;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Edit1: TEdit;
        Button1: TButton;
        Button2: TButton;
        Edit2: TEdit;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    var
      d, q, w, py: array[0..100] of integer;
      zm: array[0..31, 0..100] of integer;
      k: integer; //&AElig;&laquo;&Ograve;&AElig;&Aacute;&iquest;&Ecirc;&yacute;×é&micro;&Auml;&Ecirc;&yacute;×é&sup3;¤&para;&Egrave;
    procedure TForm1.Button1Click(Sender: TObject);
    var
      i: integer;
      temp: string;
      single: char;
      sinstr: string;
    begin
      temp := '';
      sinstr := '&Iacute;&pound;&Iacute;&brvbar;';
      //   while i<=length(sinstr) do   //&para;&Ocirc;&Oacute;&brvbar;&sup1;&Oslash;&Iuml;&micro;  ±&frac34;&sup3;&Igrave;&ETH;ò&Eacute;ú&sup3;&Eacute;&Ecirc;&yacute;&frac34;&Yacute;&Icirc;&ordf;205 163 &frac14;&acute;CDA3  &Ccedil;&oslash;&Icirc;&raquo;&Ecirc;&auml;&Egrave;&euml;·¨&Icirc;&ordf;4503
      for i := 1 to length(sinstr) do begin
        single := sinstr[i];
        d[i] := ord(single) - 160;
        if d[i] < 10 then
          temp := temp + '0' + inttostr(d[i])
        else temp := temp + inttostr(d[i]);
      end;
      Edit1.text := temp;
      i := 1;
      while (i * 2 <= length(sinstr)) do begin
        q[i] := d[i * 2 - 1];
        w[i] := d[i * 2];
        if (q[i] < 10) and (w[i] < 10) then
          Edit2.text := Edit2.text + '0' + inttostr(q[i]) + '0' + inttostr(w[i])
        else if (q[i] < 10) and (w[i] >= 10) then
          Edit2.text := Edit2.text + '0' + inttostr(q[i]) + inttostr(w[i])
        else if (q[i] >= 10) and (w[i] < 10) then
          Edit2.text := Edit2.text + inttostr(q[i]) + '0' + inttostr(w[i]);
        i := i + 1;
      end;
      for k := 0 to i - 1 do begin
        py[k] := (q[k] - 1) * 94 + (w[k] - 1) * 32;
      end;
      showmessage(inttostr(py[0]));
    end;type
      TPersonRec = record
        data: string[2];
      end;procedure TForm1.Button2Click(Sender: TObject);
    var
    //  mytextfile:textfile;  //&Eacute;ù&Atilde;÷&Ograve;&raquo;&cedil;&ouml;&Icirc;&Auml;±&frac34;&Icirc;&Auml;&frac14;&thorn;
      personrec: TPersonRec; //&Eacute;ù&Atilde;÷&Ograve;&raquo;&cedil;&ouml;&Agrave;à&ETH;&Iacute;&Icirc;&Auml;&frac14;&thorn;
      datafile: file of TPersonRec;  i: integer;
      s: string;
      buf:array [0..31] of string;
    begin
      assignfile(datafile, 'hzk16.dat');
      reset(datafile);
      seek(datafile,py[1]);
      BlockRead(datafile,buf,31);
      showmessage(buf[30]);
      CloseFile(datafile);
    end;end.
      

  11.   

    有那么复杂吗?将汉字或者数字画到一个16*16点阵或者8*8点阵的CNAVAS上,然后扫描出来不就可以了?打到液晶屏上的时候按照点阵还原即可,有1的地方亮灯,该字符就显示出来了。大佬有一个例子,带源码的,扫描和还原都有,你可以去看看。---
    软件大佬,基于软件行业的研发、学习、交易、服务、管理的网络平台,您事业开始的
    地方。请访问www.softboss.com
      

  12.   

    type
     buffer=Array[0..31] of Char;
     THzMap=Class
     private
       buff: buffer;
       fs:TFileStream;
     public
       Constructor Create(Const filename:string);
       destructor destroy;override;
       Function GetMap(Const hzgb:String):PChar;
     end;
    destructor THzMap.destroy;
    begin
       FreeAndNil(fs);
    end;
    Constructor THzMap.Create(Const filename:string);
    begin
       Fs:=TFileStream.Create(filename,fmOpenRead);
       fillchar(buff,sizeof(buff),0);
    end;Function THzmap.GetMap(Const hzgb:String):PChar;
    var qu,wei,offset:integer;
    begin
       Result:=Nil;
       if length(hzgb)<>2 then
         exit;
       qu:=ord(hzgb[1])-$a0;
       wei:=ord(hzgb[2])-$a0;
       offset:=(94*(qu-1)+(wei-1))*32;
       if offset>fs.Size-32 then
         exit;
       fs.Seek(offset,soFromBeginning);
       fs.Read(buff,32) ;
       Result:=PChar(@buff);
    end;