Skip to content

Convert image files into C arrays of uint8_t for compiling into your project

License

Notifications You must be signed in to change notification settings

bitbank2/image_to_c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image_to_c

Added GUI wrapper. For windows run 'Image2cGUI.exe' and for Mac run 'Image2cGUI'. alt_text
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:

It turns this type of file:
Animated GIF

Into this type of file:
screenshot

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.

paypal

About

Convert image files into C arrays of uint8_t for compiling into your project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published