Skip to content

Commit 2bd4d4c

Browse files
committed
Clean up image export instructions, BMP example
1 parent 69d055b commit 2bd4d4c

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,21 @@ SPI (4 wire) driver for the SSD1331 OLED display.
99
<!-- See the [announcement blog post](https://wapl.es/electronics/rust/2018/04/30/ssd1331-driver.html) for more information. -->
1010

1111
The display is configured by this driver to use a 16 bit, R5 G6 B5 pixel definition.
12-
You can convert images into the correct RAW format with the following commands (assumes 8x8 PNG input):
12+
You can convert images into the correct BMP format with the following commands:
1313

1414
```bash
15-
convert ferris.png -flip -type truecolor -define bmp:subtype=RGB565 -depth 16 -strip ferris.bmp
16-
17-
# Where 128 is (width * height * 2)
18-
tail -c 128 ferris.bmp > ferris.raw
15+
convert my_image.png -flip -type truecolor -define bmp:subtype=RGB565 -depth 16 -strip my_image.bmp
1916
```
2017

18+
You can also export images directly from The GIMP by saving as `.bmp` and choosing the following option:
19+
20+
![The GIMP RGB565 export option.](readme_gimp_export.png?raw=true)
21+
2122
## [Documentation](https://docs.rs/ssd1331)
2223

2324
## [Examples](examples)
2425

25-
From [`examples/image.rs`](examples/image.rs):
26+
Load a BMP and display it in the center of the display. From [`examples/bmp.rs`](examples/bmp.rs):
2627

2728
```rust
2829
#![no_std]
@@ -78,7 +79,12 @@ fn main() -> ! {
7879
disp.init().unwrap();
7980
disp.flush().unwrap();
8081

81-
let im = Image1BPP::new(include_bytes!("./ferris.raw"), 86, 64).translate(Coord::new(5, 0));
82+
// 16BPP, RGB565-format BMP image
83+
let im = ImageBmp::new(include_bytes!("./rust-pride.bmp")).unwrap();
84+
85+
let centered = im.translate(Coord::new((96 - im.width() as i32) / 2, 0));
86+
87+
disp.draw(centered.into_iter());
8288

8389
disp.draw(im.into_iter());
8490
disp.flush().unwrap();

readme_gimp_export.png

25.4 KB
Loading

0 commit comments

Comments
 (0)