Take your 4 bit per pixel grayscale OLED bitmaps and compress them to a more reasonable size, add transparency, and generate a header file automatically with fast decompression and easy microcontroller usage.
This library is designed to work with 128x128 SSD1327 OLED displays but could be adapted quite easily to other displays
- Windows 10 Version 10.0
- macOS Big Sur Version 11.4
Note that the macOS version must be run from source, a single file will hopefully be released soon
- Preparing your bitmap
- Create your bitmap image in your favorite image editing tool (this will be in Adobe Photoshop but there should be similar options in other tools)
- When saving the file, be sure to choose the .bmp file format and 4 bit pixel depth
- Note: Do not choose to compress it when saving! Compressing it now has no real benefit
- Compressing the bitmap
- Download the latest release from the release section
- Open the program and it should come up with a GUI that looks similar to this

- Go to File ► Open and find the bitmap you saved earlier
- The program will now read your file in and a preview of it should show up in the top right
- *Note: The compress checkbox will automatically be selected if your bitmap data is smaller when compressed (if compressed size < uncompressed size)
- You should also see a preview of what the header file will look like below the bitmap and data
- You can now File ► Save As if there is no transparency in your image, otherwise proceed to the next part
- Working with transparency
- Transparent pixels are defined as any pixel which should not be drawn, meaning the bitmap will use whatever value is already in the pixel buffer at that location
- By selecting the transparency checkbox, transparency is enabled, and a transparent pixel designator can be selected via the drop down box
- The pixels which will be transparent will show in the preview as red, updated whenever a setting is changed, similar to this

- In order to have transparency, one pixel value (
0x0-0xF) must be designated to not be drawn and instead represent all transparent pixels. To make this as flexible as possible, it is not a fixed value and can be different for every bitmap
- Decompressing
- Use the
void Decompress(uint8_t x, uint8_t y, bitmap_instance bitmap)method to decompress the data directly into a pixel buffer - x and y represent the coordinates you want to draw (from top left corner) and bitmap is the name of the bitmap being decompressed
- You can also use the
void Decompress(bitmap_instance bitmap)when decompressing a full screen bitmap which is much faster but only works when dealing with images that are the exact size of the screen drawn at (0,0) - Note: Unlike traditional bitmap image drawing methods, this one does not require the width, height, or any other data about the bitmap, it is all stored in the struct
- Use the
- CPPDecompressionMethods.hpp
- This file contains all the methods that are required for doing the decompression, copy the free function out of this file into your implementation
- The
Pixelmethod will need to be adapted for the graphics library you are using, and if you want to use the full screen decompressionvoid Decompress(bitmap_instance bitmap)you will need to changepixel_bufferto whatever the name of your pixel buffer array is
- Bitmap.hpp
- This is the base struct for which all bitmap structs are derived from, providing a consistent interface and strong type checking of the data
Examples for using are planned to be added in the future
Refer to the requirement.txt document for library information when working from source.
This software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.