Giter Site home page Giter Site logo

vult0306 / bmptoarray Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sparkfun/bmptoarray

0.0 0.0 0.0 888 KB

Python script to convert a bitmap to an Arduino prog_mem array for outputting grayscale images to OLEDs.

Home Page: https://www.sparkfun.com/

Python 100.00%

bmptoarray's Introduction

SparkFun Bitmap to Progmem Array

SparkFun Micro OLED Breakout

SparkFun Flexible Grayscale Display (SPX-14543)

This script takes in a bitmap and converts the bitmap into 4-bit grayscale. An array of bytes is generated that can be copy/pasted into a header file.

This is very useful if you have a bitmap that you'd like to output onto a grayscale display (like the SparkFun flexible OLED). I attempted to use the bitmap2lcd program but found it very hard to use and over blown (and costs money) to generate an image array.

Three bitmaps are provided as an example. Requires python v2.7.

To use your own image:

  • Convert your JPEG or whatever format to BMP
  • Down convert the BMP to Black and White only. This should retain the grayscale components but remove any color information. We use paint.net and recommend it for use with this repo.
  • Run the python script against your bitmap
  • An output.txt file will be generated. Copy and paste the contents of this file to a image.h file
  • Send this array to the display of your choice. See the example below about how to implement the header file.

Usage:

python bmptoarray.py macaque.bmp

Example output:

static const unsigned char myGraphic[2560] PROGMEM = {
0xf, 0xf0, 0x44, 0x44, 0x44, 0x44, 
0x84, 0xa9, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 
0xaa, 0x6a, 0x44, 0x44, 0x54, 0xa9, 0xaa, 0xaa, 
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a, 0x25, 0x22, 

You can find an example of how to implement the header file here.

This is pretty much my first hack at python so I greatly welcome improvements with a pull request.

License Information

This product is open source!

The code is released under the GPL v3 license. See the included LICENSE.md for more information.

Distributed as-is; no warranty is given.

  • Your friends at SparkFun.

bmptoarray's People

Contributors

nseidle 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.