完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
s3c2410板子,zc301摄像头采集图像,利用framebuffer在LCD上显示,利用jpeglib.h解压图像时,出现错误,如图所示:程序源码如下; 请各位大神帮忙指点一下,,谢谢啦 /usr/include/jpeglib.h:914:parse error before "FILE"
#include #include #include #include #include #include #include #include "v4l.c" #include "v4l.h" #include #include //#include //#include //#include //#include #define norm VIDEO_MODE_NTSC #define DEFAULT_FIL_NAME "picture" unsigned short RGB888toRGB555(unsigned char red,unsigned char green,unsigned char blue) {unsigned short B=(blue>>3)&0x001F; unsigned short G=((green>>2)<<5)%0x07E0; unsigned short R=((red>>3)<<11)&0xF800; return (unsigned short )(R|G|B); } int fb_pixel(void *fbmem,int width,int height,int x,int y,unsigned short color) {if((x>width)||(y>height)) return (-1); unsigned short *dst=((unsigned short *)fbmem+y*width+x); *dst=color; return 0; } 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; long int location=0; int sav=0; fbfd=open("/dev/fb0",O_RDWR); if(!fbfd){ printf("Error:can't open framebuffer device.n"); exit(1); } printf("the framebufffer device was opened successfully.n"); if(ioctl(fbfd,FBIOGET_FSCREENINFO,&finfo)){ printf("Error:read fixed information .n"); exit(2); } if(ioctl(fbfd,FBIOGET_VSCREENINFO,&vinfo)){ printf("Error:reading variable information.n"); exit(3); } printf("vinfo.xres=%dn",vinfo.xres); printf("vinfo.yres=%dn",vinfo.yres); printf("vinfo.bits_per_bits=%dn",vinfo.bits_per_pixel); printf("vinfo.xoffset=%dn",vinfo.xoffset); printf("vinfo.yoffset=%dn",vinfo.yoffset); printf("finfo.line_length=%dn",finfo.line_length); screensize=vinfo.xres*vinfo.yres*vinfo.bits_per_pixel/8; fbp=(char *)mmap(NULL,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.n"); int i=1; v4ldevice VD; v4ldevice *vd=&VD; char *buffer=NULL; v4l_open("/dev/video0",vd); //打开设备 v4l_grab_init(vd,NTSC_WIDTH,NTSC_HEIGHT); v4l_mmap_init(vd); //开始获取图 v4l_grab_sync(vd,vd->frame_current);//等待传完一帧 while(1) { vd->frame_current^=1; v4l_grab_start(vd,vd->frame_current); v4l_grab_sync(vd,vd->frame_current); buffer=(char *)v4l_get_address(vd);//得到这一帧的地址 printf("img address %pn",buffer); struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; FILE * infile; // (void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); unsigned char *buffer1; if((infile=fopen(buffer,"rb"))==NULL){ fprintf(stderr,"open %s failedn",*buffer); exit(-1); } cinfo.err=jpeg_std_error(&jerr); jpeg_create_decompress(&cinfo); jpeg_stdio_src(&cinfo,infile); jpeg_read_header(&cinfo,TRUE); jpeg_start_decompress(&cinfo); if((cinfo.output_width>vinfo.xres)||(cinfo.output_height>vinfo.yres)){ printf("too large JPEG file,can't displayn"); return (-1); } buffer1=(unsigned char *)malloc(cinfo.output_width*cinfo.output_components); y=0; while(cinfo.output_scanline if(vinfo.bits_per_pixel==16){ unsigned short color; for(x=0;x fb_pixel(fbp,vinfo.xres,vinfo.yres,x,y,color); } }else if(vinfo.bits_per_pixel==24){ memcpy((unsigned char *)fbp+y*vinfo.xres*3,buffer1,cinfo.output_width*cinfo.output_components); } y++; } jpeg_finish_decompress(&cinfo); jpeg_destroy_decompress(&cinfo); free(buffer1); fclose(infile); } v4l_close(vd); return 0; }
|
|
相关推荐
5个回答
|
|
平台: redhat 9.0
|
|
|
|
解析错误,将含 FILE 定义的 #include
|
|
|
|
将变量定义全部放在main()开头试试。
|
|
|
|
解析错误
Applications using the JPEG library should include the header file jpeglib.h to obtain declarations of data types and routines. Before including jpeglib.h, include system headers that define at least the typedefs FILE and size_t. On ANSI-conforming systems, including 将含 FILE 定义的 stdio.h移到 jpeglib.h前面 |
|
|
|
头文件放置有问题
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
迅为RK3568开发板EMMC镜像导出打包update.img
403 浏览 0 评论
飞凌嵌入式-ELFBOARD 硬件知识分享-ELF 2电源电路讲解
1004 浏览 0 评论
1713 浏览 0 评论
飞凌嵌入式ElfBoard ELF 1板卡-mfgtools烧录流程介绍之烧写所需镜像
1511 浏览 0 评论
飞凌嵌入式ElfBoard ELF 1板卡-mfgtools烧录流程之烧写方法
956 浏览 0 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-26 13:13 , Processed in 0.793913 second(s), Total 84, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号