Git Product home page Git Product logo

binaryconv's Introduction

Mono Image to Binary Array Converter

This command line utility will load most common image formats and output a C/C++ header file that can be used in Arduino or similar platforms to draw it as a bitmap from a byte array.

Usage:

binaryconv imagepath [outputname]

So basically given a monochrome image like this:

sample

...you get output like:

#define image_width 128
#define image_height 9

const uint8_t PROGMEM image_data[] = {
    B00111111, B11110000, B10000110, B00010010, B00000100, B11111110, B01111111,
    B11111000, B00000010, B00011111, B11111000, B01111111, B11110001, B11111111,
    B11100000, B10000000, B01000000, B00001000, B01001001, B00100001, B00000101,
    B10000000, B01000000, B00000000, B00000010, B00100000, B00000100, B10000000,
    B00001001, B00000000, B00000001, B00000000, B01000000, B00000100, B01001001,
    B00100000, B10000101, B01000000, B01000000, B00000000, B00000010, B01000000,
    B00000100, B10000000, B00001001, B00000000, B00000010, B00000000, B01000000,
    B00000000, B01001001, B00100000, B01000101, B00100000, B01000000, B00000000,
    B00000010, B00000000, B00000100, B10000000, B00001001, B00000000, B00000100,
    B00000000, B00111111, B11111000, B01001001, B00100000, B00100101, B00010000,
    B00100000, B00000111, B11111110, B00011111, B11111100, B11111111, B11111000,
    B10000000, B00000111, B11111111, B00000000, B00000100, B01001001, B00100000,
    B00010101, B00001000, B00010000, B00000000, B00000010, B00000000, B00000100,
    B10000000, B00001000, B01000000, B00000100, B00000000, B01000000, B00000100,
    B01001001, B00100000, B00001101, B00000100, B00001100, B00000000, B00000010,
    B01000000, B00000100, B10000000, B00001000, B00110000, B00000010, B00000000,
    B00100000, B00001000, B00110000, B11000011, B11111001, B00000010, B00000011,
    B00000000, B00000010, B00100000, B00000100, B10000000, B00001000, B00001100,
    B00000001, B00000000, B00011111, B11110000, B00000000, B00000000, B00000000,
    B00000000, B00000000, B11111000, B00000010, B00011111, B11111000, B00000000,
    B00000000, B00000011, B11100000, B10000000,
};

The bytes are arranged into rows of 7 each, each bit is literally 1 or 0.

Please make sure the image is already monochrome going in, this simply uses the value of "B" (from RGB) so it assumes you dithered it and did color reduction in a graphics program before running this utility.

binaryconv's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.