Embed image in code, without using resource section or external images

后端 未结 3 511
挽巷
挽巷 2020-12-11 08:59

I\'m looking for a way to embed an image in a library (Windows-only). I don\'t want to go the \'traditional\' way of putting it in the resources (because of special circumst

相关标签:
3条回答
  • 2020-12-11 09:27

    Google for a bin2c utility (something like http://stud3.tuwien.ac.at/~e0025274/bin2c/bin2c.c). It takes a file's binary representation and spits out a C source file that includes an array of bytes initialized to that data.

    Just link the file in and you have your image sitting in a chunk of memory.

    Using this kind of tool is really common on embedded systems where such things as 'resources' and even files might not exist.

    0 讨论(0)
  • 2020-12-11 09:34

    The open source application Hexy is designed specifically for this. It runs on windows and linux. https://github.com/tristan2468/Hexy

    0 讨论(0)
  • 2020-12-11 09:42

    The Gimp can export to C files. I think that would be the easiest way to do it.

    0 讨论(0)
提交回复
热议问题