操作系统:Ubuntu14.04
内核版本:Linux version 4.4.0-130-generic
交叉编译工具:gcc-3.4.5-glibc-2.3.6
libjpeg库版本:jpegsrc.v9c
材料准备:4.3(480*272)寸jpg图像,编译好的生成文件,上传到开发板(可以参考我之前写过的文章)
代码如下(包含BMP和JPGE代码),详情请看代码注释
欢迎大家在评论留言~~~~~~~~~~~~~~~~
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/input.h>
#include <sys/mman.h>
//jpeg库的标准头文件
#include <stdio.h>
#include "jpeglib.h"
#include <setjmp.h>
int lcd; //全局变量
short * fb_mem; //这块的数据类型一定要注意,如果使用就要跟一个像素匹配两个字节(一个像素由多少个字节组成有关)
/*jpeg显示所需的结构体*/
struct my_error_mgr {
struct jpeg_error_mgr pub; /* "public" fields */
jmp_buf setjmp_buffer; /* for return to caller */
};
typedef struct my_error_mgr * my_error_ptr;
/*jpeg显示所需的结构体*/
METHODDEF(void)
my_error_exit (j_common_ptr cinfo)
{
/* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
my_error_ptr myerr = (my_error_ptr) cinfo->err;
/* Always display the message. */
/* We could postpone this until after returning, if we chose. */
(*cinfo->err->output_message) (cinfo);
/* Return control to the setjmp point */
longjmp(myerr-