免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 10189 | 回复: 25
打印 上一主题 下一主题

如何把图片通过framebuffer写到屏上 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-10-28 17:22 |只看该作者 |正序浏览
请教高手,如何把图片通过framebuffer直接写到显示器上,redhat系统上

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
26 [报告]
发表于 2009-03-10 21:21 |只看该作者
原帖由 aokikyon 于 2009-3-10 21:07 发表
我在单纯的linux内核上是把一张lcd大小的图片转换为bin(565)格式,然后直接cp到fb0就行了

那如果是100张图片呢?也这么做吗?

论坛徽章:
0
25 [报告]
发表于 2009-03-10 21:07 |只看该作者
我在单纯的linux内核上是把一张lcd大小的图片转换为bin(565)格式,然后直接cp到fb0就行了

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
24 [报告]
发表于 2009-03-10 14:45 |只看该作者
高手给点资料吧,我也没研究过这个

论坛徽章:
0
23 [报告]
发表于 2009-03-10 14:31 |只看该作者

回复 #22 T-bagwell 的帖子

。。我以前没接触过这个。。没点基础。。现在要做一个双屏幕输出。显示不同的内容。一个是vag  一个是lvds  给推荐点资料看看。。谢谢哈~

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
22 [报告]
发表于 2009-03-10 13:15 |只看该作者
原帖由 wo306964521 于 2009-3-10 12:59 发表
如果我是用2个屏幕呢?该怎么弄?

分情况
不管怎么样
那就是驱动层的问题了
shared memory应该可以做到了

论坛徽章:
0
21 [报告]
发表于 2009-03-10 12:59 |只看该作者

回复 #20 T-bagwell 的帖子

如果我是用2个屏幕呢?该怎么弄?

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
20 [报告]
发表于 2009-03-05 22:34 |只看该作者

  1. /**************************************************
  2. *                example5.c
  3. *        Author:        T-bagwell
  4. *
  5. *        Compile:gcc -Wall example5.c -o example5
  6. *************************************************/
  7. #include <stdio.h>
  8. #include <unistd.h>
  9. #include <sys/types.h>
  10. #include <sys/stat.h>
  11. #include <fcntl.h>
  12. #include <linux/fb.h>
  13. #include <errno.h>
  14. #include <sys/mman.h>
  15. #include <stdlib.h>
  16. #include <string.h>
  17. #include <sys/ioctl.h>
  18. #include <jpeglib.h>
  19. #include <jerror.h>


  20. int print_screen(short *buf,int width,int height);
  21. void draw_hline(short *buffer,int x,int y,int maxy,int maxx);

  22. char *fb_addr;
  23. unsigned int    fb_width;
  24. unsigned int    fb_height;
  25. unsigned int    fb_depth;
  26. unsigned fb_size;

  27. unsigned short PIXELRGB888TO565(unsigned char red, unsigned char green, unsigned char blue)
  28. {
  29.         unsigned short  B = (blue >> 3) & 0x001F;
  30.         unsigned short  G = ((green >> 3) << 5) & 0x07E0;
  31.         unsigned short  R = ((red >> 3) << 11) & 0xF800;

  32.         return (unsigned short) (R | G | B);
  33. }

  34. int draw_pixel(void *fbmem, int width, int height, int x, int y, unsigned short color)
  35. {
  36.         if ((x > width) || (y > height))
  37.                 return -1;

  38.         unsigned short *dst = ((unsigned short *) fbmem + y * width + x);

  39.         *dst = color;
  40.         return (0);
  41. }


  42. int main(int argc, char *argv[])
  43. {
  44.         int screen_fbd=0;
  45.         struct jpeg_decompress_struct cinfo;
  46.         struct jpeg_error_mgr jerr;
  47.         FILE           *infile;
  48.         struct fb_fix_screeninfo fb_fix;
  49.         struct fb_var_screeninfo fb_var;
  50.         char *env=NULL;
  51.         unsigned char  *buffer;
  52.         unsigned char  *fbmem;
  53.         short *color_white;
  54.         unsigned short  color;
  55.         unsigned int    x;
  56.         unsigned int    y;
  57.         if ((infile = fopen(argv[1], "rb")) == NULL)
  58.         {
  59.                 fprintf(stderr, "open %s failed\n", argv[1]);
  60.                 exit(-1);
  61.         }

  62.         if(!(env = getenv("FRAMEBUFFER")))
  63.         {
  64.                 env = "/dev/fb0";
  65.         }

  66.         screen_fbd = open(env, O_RDWR);

  67.         if(screen_fbd < 0)
  68.         {
  69.                 return 0;
  70.         }

  71.         if(ioctl(screen_fbd, FBIOGET_VSCREENINFO, &fb_var) == -1)
  72.         {
  73.                 close(screen_fbd);
  74.                 return 0;
  75.         }
  76.         fb_width = fb_var.xres;
  77.         fb_height = fb_var.yres;
  78.         fb_depth = fb_var.bits_per_pixel;

  79.         cinfo.err = jpeg_std_error(&jerr);
  80.         jpeg_create_decompress(&cinfo);

  81.         jpeg_stdio_src(&cinfo, infile);
  82.         jpeg_read_header(&cinfo, TRUE);
  83.         jpeg_start_decompress(&cinfo);
  84.         if ((cinfo.output_width > fb_width) ||(cinfo.output_height > fb_height))
  85.         {
  86.                 return (-1);
  87.         }

  88.         fbmem = mmap(0, fb_width * fb_height, PROT_READ | PROT_WRITE, MAP_SHARED, screen_fbd, 0);
  89.         buffer = (unsigned char *) malloc(cinfo.output_width * cinfo.output_components);
  90.         y = 0;

  91.         while (cinfo.output_scanline < cinfo.output_height)
  92.         {
  93.                 jpeg_read_scanlines(&cinfo, &buffer, 1);
  94.                 if (fb_depth == 16)
  95.                 {
  96.                         for (x = 0; x < cinfo.output_width; x++)
  97.                         {
  98.                                 color = PIXELRGB888TO565(buffer[x * 3], buffer[x * 3 + 1], buffer[x * 3 + 2]);
  99.                                 draw_pixel(fbmem, fb_width, fb_height, x, y, color);
  100.                         }
  101.                 }
  102.         y++;
  103.         }
  104.         jpeg_finish_decompress(&cinfo);
  105.         jpeg_destroy_decompress(&cinfo);

  106.         free(buffer);
  107.         return 0;
  108. }


复制代码


详细的步骤在 这个板块找我写的帖子就可以了 ,图形基础,希望上面代码会有用

论坛徽章:
0
19 [报告]
发表于 2009-03-05 15:34 |只看该作者

回复 #10 jixiang19850126 的帖子

怎么在字符界面显示图片啊?教教俺。。谢谢哈

论坛徽章:
0
18 [报告]
发表于 2008-11-05 16:43 |只看该作者
打开/dev/fb0, 然后ioremap, 然后直接往显存里面放图片数据就ok了。
  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP