A simple utility to encode a file (or any other data) into a C byte array.
Having set up your Go environment, simply run
go get github.com/cratonica/2carray
Then use by piping a file into the utility and capturing the output. You must provide a name for the generate array symbol. For example:
$GOPATH/bin/2carray my_image < myimage.png > my_image.h
This will output something like:
#ifndef MY_IMAGE_H_INCLUDED
#define MY_IMAGE_H_INCLUDED
const unsigned char my_image[] = {
0x49, 0x20, 0x63, 0x61, 0x6e, 0x27, 0x74, 0x20, 0x62, 0x65, 0x6c, 0x69,
0x65, 0x76, 0x65, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x61, 0x63, 0x74, 0x75,
0x61, 0x6c, 0x6c, 0x79, 0x20, 0x64, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x64,
0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x20, 0x4b, 0x75, 0x64, 0x6f, 0x73,
0x20, 0x66, 0x6f, 0x72, 0x20, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x20, 0x74,
0x68, 0x6f, 0x72, 0x6f, 0x75, 0x67, 0x68, 0x2e, 0x0a
};
#endif /* MY_IMAGE_H_INCLUDED */