CLI util to convert images in various formats to C arrays in various bit depths
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.clang-format
LICENSE
Makefile
README.org
main.c
stb.h
stb_image.h

README.org

img2array

Useful little commandline tool for embedded applications. Converts an image from PNG, JPG, TGA, BMP, GIF or flattened PSD to C arrays. Uses STB for image parsing, no other dependencies. Arrays are currently always exported in Little Endian order.

Usage

Usage:  img2array [options] image [ > dest.h ]
  -a STRING array alignment prefix
            (default: "")
  -e STRING array alignment suffix
            (default: "__attribute__ ((aligned (4)))")
  -n STRING array base name
            (default: image filename w/o ext)
  -m INT    destination color mode (default 0):
            0 = argb8888
            1 = rgb888
            2 = rgb565
            3 = argb4444
$ img2array -m 3 -n logo48 logo.png

#pragma once
#include <stdint.h>

const uint8_t logo48_argb4444[4608] __attribute__ ((aligned (4))) = {
0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 
...
};

Building this project

git clone git@github.com:thi-ng/img2array.git
cd img2array
make

If you want to reduce the tool’s filesize (default: ~256KB) and limit image format support, uncomment some of the #define’s in main.c.

License

This project is open source and licensed under the Apache Software License 2.0.