All Projects → thi-ng → Img2array

thi-ng / Img2array

Licence: apache-2.0
CLI util to convert images in various formats to C arrays in various bit depths

Programming Languages

c
50402 projects - #5 most used programming language
  • img2array

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

** Usage

#+BEGIN_SRC text 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 #+END_SRC

#+BEGIN_SRC text $ 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, ... }; #+END_SRC

** Building this project

#+BEGIN_SRC bash git clone [email protected]:thi-ng/img2array.git cd img2array make #+END_SRC

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 [[http://www.apache.org/licenses/LICENSE-2.0][Apache Software License 2.0]].

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].