Jul 24
Convert an image for use on OLED display
Microcontrollers and OLED displays are a common combination. And usually, the bitmaps used to render images on such displays are saved to the file-system of a microcontroller like the ESP8266 in the form of .MONO files. These files are simple bitmap files ("bitmap" not in the sense of the Bitmap .BMP file format, but in the sense that these files contain an array of bits, 1s and 0s to represent a drawn pixel or a black/not-drawn pixel on the display). That's why some people prefer to save these images as .bin files.
That's what the u8glib docs have to say about these bitmaps files:
Draw a XBM Bitmap. Position (x,y) is the upper left corner of the bitmap. XBM contains monochrome, 1-bit bitmaps. This procedure only draws pixel values 1. The current color index is used for drawing (see setColorIndex). Pixel with value 0 are not drawn (transparent). Many tools can save a bitmap as XBM.
This is not 100% correct IMHO, as the routine is not able to munge proper/full-blown .XBM files, for example from Gimp. It rather expects what the raw data in an XBM file, 0x00's and 0xFF's.
That's why many people rely on home-brewn scripts to convert images to a bi-color bitmap, people on Windows seem to use the LCD Creator for that.
I'm on Linux here and found that the readily-available ImageMagick package will do the trick for you without any scripting. And runs on the CLI! Simple as that:
convert some_image.png some.image.mono
and you're done. If you are drawing black on white, or white on black, add the -negate option for whatever you need - it will invert the tone mapping of the image.
--
This post is part of a series of Mini Tutorials on the ESP8266:
Previous post: Secret of Monkey Island on NodeMCU
Next post: Receiving UDP data with ESP8266
I'm tinkering here with a NodeMCU ESP8266 board.
I'm using the ESP8266 Java IDE ESPlorer.
The firmware is version 0.9.6 build 20150704 powered by Lua 5.1.4
--
Keywords:
2-color image old convert
bi-color image converter
monochromatic xbm linux
convert imagemagick mono xbm
convert image to mono
image convert mono
bitmap to mono oled
convert image to mono arduino oled
1-bit image for oled arduino