00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "../FBlib.h"
00017 #include <stdio.h>
00018 #include <jpeglib.h>
00019
00020 int main(int argc, char *argv[])
00021 {
00022 FB_pixel col;
00023 struct jpeg_decompress_struct cinfo;
00024 struct jpeg_error_mgr jerr;
00025 FILE *infile;
00026 JSAMPARRAY buffer;
00027 int i,j,x=0,y=0;
00028
00029 if(argc < 2)
00030 {
00031 fprintf(stderr,"usage: test image.jpg\n");
00032 exit(1);
00033 }
00034 cinfo.err = jpeg_std_error(&jerr);
00035 jpeg_create_decompress(&cinfo);
00036 if((infile = fopen(argv[1],"rb")) == NULL)
00037 {
00038 fprintf(stderr,"can't open %s\n",argv[1]);
00039 exit(1);
00040 }
00041 jpeg_stdio_src(&cinfo, infile);
00042 jpeg_read_header(&cinfo, TRUE);
00043 jpeg_start_decompress(&cinfo);
00044 buffer=(*cinfo.mem->alloc_sarray)((j_common_ptr) &cinfo, JPOOL_IMAGE, cinfo.output_width*cinfo.output_components, 1);
00045 FB_initlib("/dev/fb0");
00046 i=cinfo.output_width*cinfo.output_components*sizeof(char);
00047 FB_clear_screen(FB_makecol(0,0,0,0));
00048 while(cinfo.output_scanline < cinfo.output_height)
00049 {
00050 jpeg_read_scanlines(&cinfo, buffer, 1);
00051 j=0;
00052 while(j<=i)
00053 {
00054 col = FB_makecol(buffer[0][j],buffer[0][j+1],buffer[0][j+2],0);
00055 FB_putpixel(x,y,col);
00056 j+=3;
00057 x++;
00058 }
00059 y++;
00060 x=0;
00061 }
00062 jpeg_finish_decompress(&cinfo);
00063 jpeg_destroy_decompress(&cinfo);
00064 fclose(infile);
00065 getc(stdin);
00066 FB_exit();
00067 return 0;
00068 }
00069