Skip to content

CLI util to convert images in various formats to C arrays in various bit depths

License

Notifications You must be signed in to change notification settings

thi-ng/img2array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

CLI util to convert images in various formats to C arrays in various bit depths

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages