image_to_c
A command line tool for turning binary image files into C source code. The output is an array of unsigned chars and is sent to stdout. Included are comments detailing the image type, size and other details.
Why did you write it?
My existing tool (bin_to_c) is similar in that it generates C arrays to compile file data directly into a project. I have used this tool to create many .H files to include with my projects, but the filename alone isn't enough to know the details of the image file contained in the data. Instead of manually adding this information to each file, I came up with the idea of combining my imageinfo tool with the bin_to_c tool to make something even more useful.
What does the output look like?
Here's an example of a before and after of what this new tool does:
What image file types does it support?
PNG, JPEG, BMP, TIFF, GIF, PPM, TARGA, JEDMICS, CALS and PCX
What happens for unrecognized files?
If the file type is not known, it will generate the same C output, but without additional info.
New Feature
I just added the ability to write only the image data and strip off the header/metadata. Use the --strip option on TIFF and BMP files.
Example: ./image_to_c --strip input.bmp > output.h
This will only write the pixel data (compressed or not) to the output file
If you find this code useful, please consider sending a donation or becoming a Github sponsor.