Formats
Pixel formats
Constant |
Bits per pixel |
Buffer size for |
Typical use |
|---|---|---|---|
|
1 |
|
monochrome screens, each byte is 8 pixels down a column, low bit at the top |
|
1 |
|
monochrome screens, bytes run across, high bit on the left |
|
1 |
|
as |
|
2 |
|
four-level greyscale |
|
4 |
|
sixteen-level greyscale |
|
8 |
|
256-level greyscale |
|
16 |
|
most small colour screens |
|
24 |
|
24-bit screens and RGB LED strips |
The first seven are framebuf’s formats with framebuf’s numbering, so a
buffer laid out for framebuf works here unchanged. RGB888 is pygraphics’
own; its bytes are stored red, green, blue.
Which file each format saves as
Format |
|
|---|---|
|
PBM (P4) |
|
PGM (P5, maximum 3) |
|
PGM (P5, maximum 15) |
|
PGM (P5, maximum 255) |
|
BMP, 16-bit RGB565 |
|
PNG, always |
|
PNG, when the name ends in |
MONO_VLSB and MONO_HMSB can’t be saved directly and raise ValueError;
blit them into a MONO_HLSB framebuffer first. PNG needs the pngio module,
as Load and save images
explains.
load_image() reads PBM (P4), PGM (P5) and 16-bit RGB565 BMP files.
Romfont files
A romfont .bin file, as Font reads it, is glyph rows and nothing else:
Glyphs |
256, for characters 0–255, or 128 for 0–127 |
Bytes per glyph |
the font’s height, one byte per row |
Width |
8 pixels; the high bit of each byte is the leftmost pixel |
File size |
|
The built-in 8x8, 8x14 and 8x16 fonts come from the romfont collection.