一、交叉编译libjepg编译
tar xzf libjpeg-turbo-1.2.1.tar.gz
./configure –help
./configure --prefix=/work/project/first_project/13libjepg/libjpeg-turbo-1.2.1/tmp/ --host=arm-linux
make
make install
二、交叉编译jepg2rgb.c
arm-linux-gcc -o jpg2rgb jpg2rgb.c -I /work/project/first_project/13libjepg/libjpeg-turbo-1.2.1/tmp/include/ -L /work/project/first_project/13libjepg/libjpeg-turbo-1.2.1/tmp/lib/ –ljpeg
把库考到开发板上
cp ../libjpeg-turbo-1.2.1/tmp/lib/*so* /work/nfs_root/fs_mini_mdev/lib/
编译出来的头文件应该放入:
cd /work/project/first_project/13libjepg/libjpeg-turbo-1.2.1/tmp/include
cp * /work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux/include -rf
编译出来的库文件应该放入:
cd /work/project/first_project/13libjepg/libjpeg-turbo-1.2.1/tmp/lib
sudo cp * /work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux/lib -d –rf
现在不需要指定目录
arm-linux-gcc -o jpg2rgb jpg2rgb.c –ljpeg
1th输出源文件信息,及解压后信息
#include <stdio.h>
#include "jpeglib.h"
#include <setjmp.h>
/*
Allocate and initialize a JPEG decompression object // 分配和初始化一个decompression结构体
Specify the source of the compressed data (eg, a file) // 指定源文件
Call jpeg_read_header() to obtain image info // 用jpeg_read_header获得jpg信息
Set parameters for decompression // 设置解压参数,比如放大、缩小
jpeg_start_decompress(...); // 启动解压:jpeg_start_decompress
while (scan lines remain to be read)
jpeg_read_scanlines(...); // 循环调用jpeg_read_scanlines
jpeg_finish_decompress(...); // jpeg_finish_decompress
Release the JPEG decompression object // 释放decompression结构体
*/
/* Uage: jpg2rgb <jpg_file>
*/
int main(int argc, char **argv)
{
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
FILE * infile;
// 分配和初始化一个decompression结构体
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);
// 指定源文件
if ((infile = fopen(argv[1], "rb")) == NULL) {
fprintf(stderr, "can't open %s\n", argv[1]);
return -1;
}
jpeg_stdio_src(&cinfo, infile);
// 用jpeg_read_header获得jpg信息
jpeg_read_header(&cinfo, TRUE);
/* 源信息 */
printf("image_width = %d\n", cinfo.image_width);
printf("image_height = %d\n", cinfo.image_height);
printf("num_components = %d\n", cinfo.num_components);
// 设置解压参数,比如放大、缩小
// 启动解压:jpeg_start_decompress
jpeg_start_decompress(&cinfo);
/* 输出的图像信息 */
printf("output_width = %d\n", cinfo.output_width);
printf("output_height = %d\n", cinfo.output_height);
printf("output_components = %d\n", cinfo.output_components);
// 循环调用jpeg_read_scanlines一行一行的获得解压数据
jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
return 0;
}
使用LCD输出
#include <stdio.h>
#include "jpeglib.h"
#include <setjmp.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <linux/fb.h>
#include <string.h>
#define FB_DEVICE_NAME "/dev/fb0"
#define DBG_PRINTF printf
static int g_fd;
static struct fb_var_screeninfo g_tFBVar;
static struct fb_fix_screeninf