1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
   | 
 ReadJpegFileBuffer(const char * fileBuffer,const int filesize,char * & buf)
	{
	
	
	struct jpeg_decompress_struct	cinfo;
	struct jpeg_error_mgr			jerr;
	cinfo.err = jpeg_std_error(&jerr);	
 	jpeg_create_decompress(&cinfo);
	jpeg_stdio_src(&cinfo,(FILE*)fileBuffer,filesize);
 	jpeg_read_header(&cinfo, TRUE);
	jpeg_start_decompress(&cinfo);
	
	int h = cinfo.output_height;
	int w = cinfo.output_width;
        buf = new char[h*w*3];
	for (unsigned int i = 0;i < cinfo.image_height;i++ )
		{
		unsigned char * buftmp = buf  + i*w;
		jpeg_read_scanlines( &cinfo, &buftmp , 1);
		}
	jpeg_finish_decompress(&cinfo);
	} | 
Partager