This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Best way to compile large image data into a program for use during run time

Hello, we'd like to compile some large image files into our project, have the data available to stream to a display peripheral via LTDC+DSI peripherals. I tried to get cute and created a desktop program that imports pictures and generates C functions to set memory locations, like:

void InitImageData_Untitled_400x400_To(uint32_t img_address)
{
    *(uint32_t*) (img_address + 0x00000000) = 0xFF00A400;
    //...
}

except for larger images this function gets impossibly large and crashes my compiler. :)

So I'm done being clever, and I'm asking the experts about the Right way to do this. What is the easiest way to compile bulk image data into a program for access during runtime?

Thanks very much!

Parents
  • In a nutshell: what you have there is a block of data, so what were you thinking turning all of that into code for no good reason? Let it stay data!

    The compiler may not even have to see it. There are tools aplenty that can directly turn raw binary data into hex files, which can be merged with your program after linking. srecord is free.

    Or, if you really need it inside the executable imabe directly, there's also a very old-fashioned actual picture file format, XPM (de.wikipedia.org/.../X_PixMap) that's actually compilable C code right there. Some conversion tools can still generate it to this day (e.g. those in the netpbm library).

Reply
  • In a nutshell: what you have there is a block of data, so what were you thinking turning all of that into code for no good reason? Let it stay data!

    The compiler may not even have to see it. There are tools aplenty that can directly turn raw binary data into hex files, which can be merged with your program after linking. srecord is free.

    Or, if you really need it inside the executable imabe directly, there's also a very old-fashioned actual picture file format, XPM (de.wikipedia.org/.../X_PixMap) that's actually compilable C code right there. Some conversion tools can still generate it to this day (e.g. those in the netpbm library).

Children