2013-07-17 02:47 AM
Hello all,
I've been trying to convert JPEG files to BMP for over two weeks. I have STM3240G-EVAL which includes IJG's JPEG library in its ''demonstration builder'', however, I could not figure out how to use it. All I got is linker errors and I even cannot compile example code in the library. There is a methodology given by IJG but it wasn't of help. Actually this is a C related problem but not about STM32 itself but I thought maybe someone used the library anyway.Can anyone please help me to learn how to use this library and its functions?p.s. The most problem with the linker error is using the full library as I seen on all blogs forums etc. I tried that too. Best regards,Gunay2013-07-17 03:27 AM
well I have already used libjpeg in stm32f4discovery. it's quite fast without using any external ram .
jpeg_create_decompress(&cinfo); jpeg_mem_src(&cinfo,wait1,sizeof(wait1)); //here wait1 is a jpeg file of size 240*160 jpeg_read_header(&cinfo, TRUE); jpeg_start_decompress(&cinfo); int buffer_height =1; buffer=(JSAMPARRAY)malloc(sizeof(JSAMPROW) * buffer_height); buffer[0] = (JSAMPROW)malloc(sizeof(JSAMPLE) * row_stride); while (cinfo.output_scanline <cinfo.output_height) { jpeg_read_scanlines(&cinfo, buffer,1); sendlcd(buffer[0],480); //////****************************main output line. } //sendlcd fills 1 row of 160 pixes .this is repeated for 240times for 240 coloumns.2013-07-17 04:41 AM
Thank you for quick response, it will be of great help.
I'll update you if I can success, or fail (:Regards2013-07-17 05:04 AM
Hi,
I had a problem. Since I do not know how to read a file, I put my jpeg file in an unsigned char array in hex format. Instead of wait 1 in your code I used this array. But the problem is buffer is not defined, I am defining an unsigned char pointer called buffer but the error message says:Error[Pe167]: argument of type ''unsigned char *'' is incompatible with parameter of type ''JSAMPARRAY''How can I read the jpeg file from the array and put it into another?Thanks a lot in advance.2013-07-18 12:10 AM
Up
2013-07-18 10:39 PM
declare the buffer like this
const char myjpeg[]={here the contents of your array };remember declaring const will put your jpeg into the flash not ram. this is not necessary if you have enough ram.2013-07-18 10:44 PM
declare the buffer like this
const char myjpeg[]={here the contents of your array };remember declaring const will put your jpeg into the flash not ram. this is not necessary if you have enough ram .you also cant edit the contents if you declare it as const.jpeg_mem_src is used only for jpeg array not for file. if you want to read from file then use jpeg_stdio_src(&cinfo, infile);infile is declared as FILE* infile.2013-07-18 10:57 PM
while (cinfo.output_scanline <cinfo.output_height)
{ jpeg_read_scanlines(&cinfo, buffer,1); sendlcd(buffer[0],480); //////****************************main output line. } have you declared JSAMPARRAY buffer; /* Output row buffer */have you allocated the memory buffer=(JSAMPARRAY)malloc(sizeof(JSAMPROW) * buffer_height); buffer[0] = (JSAMPROW)malloc(sizeof(JSAMPLE) * row_stride);you need to do these steps before you call jpeg_read_scanlines