⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 用libfbx开发显示汉字的framebuffer应用程序 - loveunix_net - 中国unix-linux 技术门户 - 文章 - 系统与网络区 - 程序设计.htm

📁 S3C44B0X下的LCD (framebuffer)驱动资料与相关代码
💻 HTM
📖 第 1 页 / 共 3 页
字号:
  <TR>
    <TD bgColor=#84a5cc height=1></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=760 align=center bgColor=#ffffff 
border=0>
  <TBODY>
  <TR>
    <TD bgColor=#eeeeee height=25>
      <TABLE cellSpacing=0 cellPadding=3 width="100%" align=center border=0>
        <TBODY>
        <TR bgColor=#ebecf5>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=6"><FONT 
            color=#000000>AIX &amp; I5</FONT></A></TD>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=68"><FONT 
            color=#000000>PC Server</FONT></A></TD>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=5"><FONT 
            color=#000000>UNIX&amp;LINUX</FONT></A></TD>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=35"><FONT 
            color=#000000>存储备份</FONT></A></TD>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=37"><FONT 
            color=#000000>网络安全</FONT></A></TD>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=9"><FONT 
            color=#000000>程序设计</FONT></A></TD>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=70"><FONT 
            color=#000000>DB2家族</FONT></A></TD>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=28"><FONT 
            color=#000000>数据库版</FONT></A></TD>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=36"><FONT 
            color=#000000>中 间 件 </FONT></A></TD></TR>
        <TR bgColor=#ffffff>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=23"><FONT 
            color=#000000>前程无忧</FONT></A></TD>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=10"><FONT 
            color=#000000>行业应用</FONT></A></TD>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=69"><FONT 
            color=#000000>产品信息</FONT></A></TD>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=48"><FONT 
            color=#000000>行业入门</FONT></A></TD>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=12"><FONT 
            color=#000000>开心太平洋</FONT></A></TD>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=65"><FONT 
            color=#000000>墨香雅韵</FONT></A></TD>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=60"><FONT 
            color=#000000>免费下载</FONT></A></TD>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=2"><FONT 
            color=#000000>共建家园</FONT></A></TD>
          <TD width="11.1%">&nbsp;<A 
            href="http://www.loveunix.net/articlelist.php?id=66"><FONT 
            color=#000000>博客专区</FONT></A></TD></TR></TBODY></TABLE></TD></TR>
  <TR>
    <TD bgColor=#84a5cc height=1></TD></TR></TBODY></TABLE>
<SCRIPT language=JavaScript>
function dozoom(size){
document.getElementById('zoom').style.fontSize=size+'px'
}
</SCRIPT>

<TABLE cellSpacing=0 cellPadding=0 width=760 align=center bgColor=#ffffff 
border=0>
  <TBODY>
  <TR>
    <TD>
      <TABLE cellSpacing=0 cellPadding=0 width="98%" align=center border=0>
        <TBODY>
        <TR>
          <TD>
            <TABLE cellSpacing=0 cellPadding=0 width="98%" border=0>
              <TBODY>
              <TR>
                <TD>
                  <TABLE cellSpacing=0 cellPadding=0 width="100%" align=center 
                  bgColor=#ffffff border=0>
                    <TBODY>
                    <TR>
                      <TD width=15>&nbsp;<IMG height=11 
                        src="用libfbx开发显示汉字的framebuffer应用程序 - LoveUnix_net - 中国UNIX-LINUX 技术门户 - 文章 - 系统与网络区 - 程序设计.files/dot.gif" 
                        width=9></TD>
                      <TD height=25>您的位置:&nbsp;&nbsp;<A 
                        href="http://www.loveunix.net/index.php">首页</A> &gt;&gt; 
                        <A href="http://www.loveunix.net/articlelist.php">文章</A> 
                        &gt;&gt; <A 
                        href="http://www.loveunix.net/articlelist.php?id=51">系统与网络区</A> 
                        &gt;&gt; <A 
                        href="http://www.loveunix.net/articlelist.php?id=9">程序设计</A> 
                        &gt;&gt; 查看内容 </TD>
                      <TD>
                        <DIV align=right><A href="http://bbs.loveunix.net/" 
                        target=_blank><IMG 
                        src="用libfbx开发显示汉字的framebuffer应用程序 - LoveUnix_net - 中国UNIX-LINUX 技术门户 - 文章 - 系统与网络区 - 程序设计.files/bbsload.gif" 
                        border=0></A></DIV></TD></TR></TBODY></TABLE></TD></TR>
              <TR>
                <TD bgColor=#999999 height=2></TD></TR>
              <TR>
                <TD>&nbsp;</TD></TR>
              <TR>
                <TD class=title 
              align=middle>用libfbx开发显示汉字的framebuffer应用程序</TD></TR>
              <TR>
                <TD>&nbsp;</TD></TR>
              <TR>
                <TD bgColor=#666666 height=1></TD></TR>
              <TR>
                <TD bgColor=#cedbe5>
                  <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                    <TBODY>
                    <TR>
                      <TD align=middle>作者: 无双&nbsp;&nbsp;发布日期: 2004-4-29 
                        &nbsp;&nbsp; 查看数:
                        <SCRIPT language=JavaScript 
                        src="C:\Documents and Settings\Administrator\桌面\wangluo\console\用libfbx开发显示汉字的framebuffer应用程序 - LoveUnix_net - 中国UNIX-LINUX 技术门户 - 文章 - 系统与网络区 - 程序设计.files\function(1).htm" 
                        type=text/JavaScript></SCRIPT>
                         &nbsp;&nbsp; 出自: 
                  http://www.loveunix.net</TD></TR></TBODY></TABLE></TD></TR>
              <TR>
                <TD>&nbsp;</TD></TR>
              <TR>
                <TD>
                  <TABLE style="TABLE-LAYOUT: fixed; WORD-WRAP: break-word" 
                  cellSpacing=2 cellPadding=2 width="100%" border=0>
                    <TBODY>
                    <TR>
                      <TD class=message id=zoom>这个程序使用的字库可以在作者的网站上找到 
                        另外libfbx也是作者开发的一个封装库<BR><BR>使用libfbx开发显示汉字的framebuffer应用程序<BR><BR><BR>云飞扬 http://yfy001.myetang.com<BR>FrameBuffer 
                        就像一张画布,使用什么样子的画笔,如何画画,还需要你自己动手完成。<BR>许多控制台C程序设计中,要用到汉字进行提示或人机交互,而在控制台下显示汉子,曾经是某些中文linux厂商的秘密哦。如何编制不使用外挂中文平台就能显示汉字的C程序呢?主要的原理就是将汉字画到屏幕上,现在控制台下的中文环境zhcon也是使用了这个原理。<BR><BR>下面的方法可以帮你在西文环境下显示汉字。这种方法是调用中文汉字库进行汉字显示。国家标准规定:汉字库分94个区,每个区有94个汉字(以位作区别),每个汉字在汉字库中有确定的区和位编号,这就是汉字的区位码。每个汉字在库中是以点阵字模形式存储的,一般采用16×16点阵(32字节)、24×24点阵(72字节),每个点用一个二进制位(0或1)表示,对应在屏幕上显示出来,就是相应的汉字。<BR>  由于在中文环境下,输入的是汉字的内码,我们必须将之转换成区位码,算出偏移量,从字库中找到对应的汉字,将其字模显示即可。<BR>  内码转换成区位码方法如下:<BR>   
                        qh=c1-0xa0 
                        wh=c2-0xa0<BR>  其区位码就是:<BR>  qw=qh*0xff+wh<BR>  该汉字在字库中离起点的位置是:<BR>   
                        offset=(94*(qh-1)+(wh-1))*32L<BR>程序例:<BR>/* gbfbx.c -a 
                        simple chinese show<BR>*<BR>* By 
                        cloudfly&lt;yfy001@etang.com&gt;<BR>*<BR>*/<BR><BR>#include 
                        &lt;libfbx/libfbx.h&gt;<BR>#include 
                        &lt;libfbx/libfbx-gui.h&gt;<BR>#include 
                        &lt;stdlib.h&gt;<BR>#include 
                        &lt;unistd.h&gt;<BR>#include &lt;stdio.h&gt;<BR>#define 
                        row 2 //纵坐标放大倍数<BR>#define col 3 //横坐标放大倍数<BR>int 
                        main()<BR>{<BR>int x,y,i;<BR>char *s="中文汉子显示";<BR>FILE 
                        *fp;<BR>char buffer[32];<BR>unsigned char 
                        qh,wh;<BR>unsigned long offset;<BR><BR>fb_init(); 
                        //图形屏幕初始化<BR>fb_handle_signals();<BR>x=fb_screen-&gt;width-300; 
                        //设定 x坐标<BR>y=fb_screen-&gt;height-300; //y坐标<BR><BR>int 
                        n,j,k,m;<BR><BR>if((fp=fopen("St.cfg","rb"))==NULL)//中文字库St.cfg可以从我的主页下载。ucdos也有<BR>{<BR>fb_cleanup();<BR>return 
                        0;<BR>}<BR><BR>while(*s)<BR>{<BR>qh=*(s)-0xa0;<BR>wh=*(s+1)-0xa0;<BR>offset=(94*(qh-1)+(wh-1))*32L;//计算该汉字在字库中偏移量<BR>fseek(fp,offset,SEEK_SET);<BR>fread(buffer,32,1,fp); 
                        //取出汉字32字节的点阵字模存入buffer中(一个汉字)<BR>for(i=0;i&lt;16;i++)<BR>for(n=0;n&lt;row;n++)<BR>for( 
                        j=0;j&lt;2;j++)<BR>for( 
                        k=0;k&lt;8;k++)<BR>for(m=0;m&lt;row;m++)<BR><BR>if(((buffer[i*2+j]&gt;&gt;(7-k))&amp;0x1)!=NULL)<BR>fb_putpixel(x+8*j*col+k*col+m,y+i*row+n,0,255,0,fb_screen);<BR>//将32位字节的点阵按位在屏幕上画出来<BR>s+=2;//因为一个汉字内码占用两个字节,所以s必须加2<BR>x+=40;<BR>}<BR>return 
                        1;<BR>}<BR><BR>gcc -o gbfbx gbfbx.c -lfbx 
                        -ldl<BR>完成编译。<BR><BR>程序中使用的中文字库St.cfg可以从我的主页下载。</TD></TR></TBODY></TABLE></TD></TR>
              <TR>
                <TD>&nbsp;</TD></TR>
              <TR>
                <TD>
                  <TABLE style="TABLE-LAYOUT: fixed; WORD-WRAP: break-word" 
                  cellSpacing=2 cellPadding=2 width="100%" border=0>
                    <TBODY>
                    <TR>
                      <TD><EMBED 
                        src=http://bbs.loveunix.net/image/ibmad_bbs.swf 
                        width=760 height=70 
                        type=application/x-shockwave-flash></EMBED> 
                        <STYLE type=text/css>.BLNK {
	FONT-WEIGHT: bold; FONT-SIZE: 14px
}
</STYLE>

                        <SCRIPT type=text/javascript>
    var j,color=new Array("RED","BLUE", "BLACK");
    j=0;
    function blinkText(){
        var sections=document.getElementsByTagName("font");
        for(var i=0;i<sections.length;i++){
            var section=sections[i];
            if(section.getAttribute("blink")=="yes"){
                section.style.color=color[j];
            }
        }
        setTimeout("blinkText()",2000);
        j=(j+1)%3                		
    }
    blinkText();
</SCRIPT>
                      </TD></TR></TBODY></TABLE></TD></TR>
              <TR>
                <TD>&nbsp;</TD></TR>
              <TR>
                <TD bgColor=#cedbe5 height=2></TD></TR>
              <TR>
                <TD>&nbsp;</TD></TR>
              <TR>
                <TD align=right><A 
                  href="http://bbs.loveunix.net/viewthread.php?tid=27916" 
                  target=_blank>【论坛浏览】</A>&nbsp;<A 
                  href="http://www.loveunix.net/viewarticle.php?id=27916#reply">【我来说两句】</A>&nbsp;<A 
                  href="javascript:window.print()">【打印】</A>&nbsp;<A 
                  href="javascript:dozoom(16)">【大】</A>&nbsp;<A 
                  href="javascript:dozoom(14)">【中】</A>&nbsp;<A 
                  href="javascript:dozoom(12)">【小】</A>&nbsp;<A 
                  href="javascript:window.close()">【关闭】</A></TD></TR>
              <TR>
                <TD>&nbsp;</TD></TR>
              <TR>
                <TD>
                  <TABLE cellSpacing=1 cellPadding=3 width="100%" 
                  bgColor=#00468c border=0>
                    <TBODY>
                    <TR>
                      <TD><FONT color=#ffffff>相关评论</FONT></TD></TR>
                    <TR>
                      <TD bgColor=#ffffff>
                        <TABLE 
                        style="TABLE-LAYOUT: fixed; WORD-WRAP: break-word" 
                        cellSpacing=2 cellPadding=2 width="100%" align=right 
                        border=0>
                          <TBODY>
                          <TR>
                            <TD bgColor=#eeeeee>作者: 流氓无产者&nbsp;&nbsp;发布日期: 
                              2004-4-30</TD></TR>
                          <TR>
                            <TD>有点像原来在dos下编程啊</TD></TR>
                          <TR>
                            <TD>
                              <TABLE 
                              style="TABLE-LAYOUT: fixed; WORD-WRAP: break-word" 
                              cellSpacing=2 cellPadding=2 width="100%" 
                                border=0><TBODY>
                                <TR>
                                <TD><A href="http://bbs.loveunix.net/" 
                                target=_blank><FONT color=#ff0000><IMG 
                                alt="Welcome to LoveUnix。如果今天的到访给你带来好心情,那么别忘了明天还来啊!" 
                                src="用libfbx开发显示汉字的framebuffer应用程序 - LoveUnix_net - 中国UNIX-LINUX 技术门户 - 文章 - 系统与网络区 - 程序设计.files/headerlogo.gif"></A></FONT></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
              <TR>
                <TD>&nbsp;</TD></TR>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -