https://github.com/styropyr0/bitmap-array-generator-from-image
https://github.com/styropyr0/bitmap-array-generator-from-image
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/styropyr0/bitmap-array-generator-from-image
- Owner: styropyr0
- Created: 2024-12-11T16:35:45.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-11T16:51:29.000Z (over 1 year ago)
- Last Synced: 2024-12-11T17:36:22.145Z (over 1 year ago)
- Language: C
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SSD1306 Bitmap Generator
A Python script to convert images into bitmaps suitable for SSD1306 OLED displays. The generated bitmap is in C array format and can be used directly in your Arduino or embedded projects.
## Features
- Converts images to monochrome bitmaps.
- Outputs the bitmap in a C array format.
- Configurable threshold for black-and-white conversion.
## Prerequisites
Make sure you have Python installed along with the following dependencies:
- [Pillow](https://python-pillow.org/) (Python Imaging Library fork)
Install Pillow using pip:
```bash
pip install pillow
```
## Usage
### Command-line Execution
```bash
python bitmap_generator.py
```
- ``: Path to the input image file.
- ``: Name of the output file where the bitmap will be saved.
### Interactive Mode
Run the script without arguments to provide inputs interactively:
```bash
python bitmap_generator.py
```
You will be prompted to:
- Enter the path to the image file.
- Enter the name of the output file.
## Output Format
The output is a C array in the following format:
```c
const uint8_t PROGMEM splash[] = {
0b11000000, 0b11110000, // Example bitmap row
0b01111000, 0b00011100, // Example bitmap row
...
};
```
- Each `0b` represents a byte in binary form.
- Rows are padded to ensure byte alignment.
## Example
### Input Image:
An image `example.png`.
### Command:
```bash
python bitmap_generator.py example.png output_bitmap.c
```
### Output (`output_bitmap.c`):
```c
const uint8_t PROGMEM splash[] = {
0b11111111, 0b00000000,
0b00000001, 0b11111110,
0b00001111, 0b11111111,
...
};
```
## Additional Options
- **Threshold Adjustment**: Modify the `threshold` value in the `image_to_bitmap` function to control the black-and-white conversion. Default is `80`.
## Developer Information
- **Author**: Saurav Sajeev
- **Purpose**: Developed to simplify the process of generating bitmaps for SSD1306 OLED displays.
Feel free to contribute or report issues to improve this tool!