Save a displayio.Bitmap (and associated displayio.Palette) into a BMP file.
Project description
Introduction
Save a displayio.Bitmap (and associated displayio.Palette) into a BMP file.
Dependencies
This driver depends on:
CircuitPython 5.0 or later is required.
Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.
Installing from PyPI
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:
pip3 install adafruit-circuitpython-bitmapsaver
To install system-wide (this may be required in some cases):
sudo pip3 install adafruit-circuitpython-bitmapsaver
To install in a virtual environment in your current project:
mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install adafruit-circuitpython-bitmapsaver
Usage Example
import board
import busio
import digitalio
from displayio import Bitmap, Palette
import adafruit_sdcard
import storage
from adafruit_bitmap_saver import save_bitmap
print('Setting up SD card')
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
cs = digitalio.DigitalInOut(board.SD_CS)
sdcard = adafruit_sdcard.SDCard(spi, cs)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")
WHITE = 0xFFFFFF
BLACK = 0x000000
RED = 0xFF0000
ORANGE = 0xFFA500
YELLOW = 0xFFFF00
GREEN = 0x00FF00
BLUE = 0x0000FF
PURPLE = 0x800080
PINK = 0xFFC0CB
colors = (BLACK, RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE, WHITE)
print('Building sample bitmap and palette')
bitmap = Bitmap(16, 16, 9)
palette = Palette(len(colors))
for i, c in enumerate(colors):
palette[i] = c
for x in range(16):
for y in range(16):
if x == 0 or y == 0 or x == 15 or y == 15:
bitmap[x, y] = 1
elif x == y:
bitmap[x, y] = 4
elif x == 15 - y:
bitmap[x, y] = 5
else:
bitmap[x, y] = 0
print('Saving bitmap')
save_pixels('/sd/test.bmp', bitmap, palette)
Contributing
Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.
Documentation
For information on building library documentation, please check out this guide.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file adafruit-circuitpython-bitmapsaver-1.1.2.tar.gz
.
File metadata
- Download URL: adafruit-circuitpython-bitmapsaver-1.1.2.tar.gz
- Upload date:
- Size: 27.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a2d1d9f2e07f568414555a661799d557d12d13b7c0f3169085afefdded788f9 |
|
MD5 | 2b70dc00e9b5c4db302940bcfffdf6af |
|
BLAKE2b-256 | 4d0b7e2db4a2c59197440746d333b02bfa012f055bbc9b011343aa37ecfd0bb8 |