1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
在2440开发板上将一副BMP图片显示到LCD上(不用GUI), 我的做法是将BMP图片用mmap()函数映射到内存中,在将其读到Framebuffer设备中显示 (frambuffer有驱动),映射BMP文件可以成功,但用其返回的指针读取映射内存中的内容时出现“bus error”的错误,但映射.c文件和mp3文件就不会出现此类问题,均可以成功读取映射内存中的内容,
有没有大虾知道问题出在什么地方啊?盼解答,不胜感激! |
|
相关推荐
2个回答
|
|
#include
#include #include #include #include #define RED_COLOR 0xE0 #define GREEN_COLOR 0x1C #define BLUE_COLOR 0x03 int main() { int fbfd=0; struct fb_var_screeninfo vinfo; struct fb_fix_screeninfo finfo; long int screensize=0; char *fbp=0; int x=0,y=0; fbfd=open("/dev/fb0",O_RDWR); if(!fbfd) { printf("Error:can't open framebuffer device.n"); exit(1); } printf("The framebuffer was opened successfully.n"); if(ioctl(fbfd,FBIOGET_FSCREENINFO,&finfo)) { printf("Error reading fixed information.n"); exit(2); } if(ioctl(fbfd,FBIOGET_VSCREENINFO,&vinfo)) { printf("Error reading variable information.n"); exit(3); } screensize=vinfo.xres*vinfo.yres*vinfo.bits_per_pixel/8; printf("%dx%d:%dbpp,screensize=%dn",vinfo.xres,vinfo.yres, vinfo.bits_per_pixel,screensize); fbp=(char *)mmap(0,screensize,PROT_READ|PROT_WRITE,MAP_SHARED,fbfd,0); if((int)fbp==-1) { printf("Error:failed to map framebuffer device to memory.n"); exit(4); } printf("The framebuffer device was mapped to memory successfully"); x=100; y=100; if(vinfo.bits_per_pixel==16) { printf("16bpp framebuffer testn"); printf("a byte in fbp is a pixel of LCD,just set the value of fbp to put color to LCDn"); printf("byte format:n"); printf("bit:|7 6 5| 4 3 2 |1 0|n"); printf(" |red |green |blue|n"); printf("Red Screenn"); for(y=0;y<240;y++) { for(x=0;x<320;x++) { *(fbp+y*320+x)=RED_COLOR; } } sleep(2); printf("Green Screenn"); for(y=0;y<240;y++) {for(x=0;x<320;x++) { *(fbp+y*320+x)=GREEN_COLOR; } } sleep(2); printf("Blue Screenn"); for(y=0;y<240;y++) {for(x=0;x<320;x++) { *(fbp+y*320+x)=BLUE_COLOR; } } sleep(2); printf("Grid Screenn"); for(y=0;y<240;y++) {for(x=0;x<320;x++) { *(fbp+y*320+x)=x; } } sleep(2); } else { printf("16bpp only!!!n"); } munmap(fbp,screensize); close(fbfd); return 0; } |
|
|
|
#include
#include #include #include #include #include #include int main(int argc,char *argv[]) { int fdin; char *src; struct stat statbuf; long len; int i; fdin=open(argv[1],O_RDONLY); printf("open bmp successfully!n"); fstat(fdin,&statbuf); printf("bmp stat rightn"); len=statbuf.st_size; printf("%dn",len); src=mmap(0,len,PROT_READ,MAP_SHARED,fdin,0); printf("bmp file mmap successfullyn"); printf("%xn",*src); close(fdin); munmap(src,len); } |
|
|
|
只有小组成员才能发言,加入小组>>
197个成员聚集在这个小组
加入小组为什么点亮LED的例子放在NORFlash上跑会出现奇怪的现象?
2177 浏览 6 评论
1982 浏览 5 评论
韦东山老师推出的《玩转ARM裸机实战》课程将帮你以上问题一扫而光!
4540 浏览 1 评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-21 18:11 , Processed in 0.626507 second(s), Total 80, Slave 61 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号