cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with JPEGFileLoader

AlexOli
Associate

I have been trying to make the demo found here https://support.touchgfx.com/docs/development/ui-development/scenarios/loading-images-at-runtime#loading-jpeg-files work, but it does not. I am trying to make it work on another empty TouchGFX 4.22.0 project but with no success. I am getting this error. Please help.

 

1 REPLY 1

Hello @AlexOli ,

Sorry for the inconvenience, to fix the issues do the following:
1- For the first error (invalid conversion), add '(FILE*)' before fileHandle so it would look like this 

jpeg_stdio_src(&cinfo, (FILE*)fileHandle);

2- For the second error (no previous declaration), simply add a declaration before the function implementation in JPEGFileInput.cpp.

extern "C"
{
    size_t jpeg_read_file(FILE* file, uint8_t* buf, uint32_t sizeofbuf);
    size_t jpeg_read_file (FILE *file, uint8_t *buf, uint32_t sizeofbuf)
    {
        return touchgfx::fileinput::readFile(file, buf, sizeofbuf);
    }
}

3- Please change the order of the colors in the struct RGB to BGR in JPEGFileLoader.cpp, so it would be:

    struct RGB
    {
        uint8_t B;
        uint8_t G;
        uint8_t R;
    };

4- Make sure that the test image is placed next to simulator.exe in build/bin directory

5- Just in case, don't forget to define a dynamic bitmap first and then use the loader.

It's also worth mentioning that you don't need to use the provided LibJPEG library in the example. TouchGFX has the required files now (the example is pretty old unfortunately).

I hope this helps you, don't hesitate to ask more questions

Mohammad MORADI
ST Software Developer | TouchGFX