bitbank2 / image_to_c

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

License:Apache License 2.0


Languages

Language:C 87.0%Language:Python 12.4%Language:Makefile 0.5%