https://github.com/nicolasbauw/blitter
Yet another bitmap blitting library for Rust.
https://github.com/nicolasbauw/blitter
bitmap blit blitter blitting framebuffer rust
Last synced: about 2 months ago
JSON representation
Yet another bitmap blitting library for Rust.
- Host: GitHub
- URL: https://github.com/nicolasbauw/blitter
- Owner: nicolasbauw
- License: mit
- Created: 2020-01-21T15:58:19.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-14T13:23:01.000Z (almost 4 years ago)
- Last Synced: 2024-03-15T03:55:11.182Z (about 1 year ago)
- Topics: bitmap, blit, blitter, blitting, framebuffer, rust
- Language: Rust
- Homepage:
- Size: 104 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# blitter
[](https://crates.io/crates/blitter)
[](https://crates.io/crates/blitter)This library performs various blitting and drawing operations on a raw 32 bits framebuffer, whatever the encoding.
- Bitmap blitting / cropping
- Blit a part of bitmap (ie. bitmap fonts)
- Blit with a color or bits mask
- Pixel plotting
- Optional PNG decoding featureExample:
```
// Framebuffer initialization
let mut pixels: Vec = vec!(0; WIDTH * HEIGHT);
let mut fb = Framebuffer {width: WIDTH, height: HEIGHT, pixels: &mut pixels};// For example, you can push all the bitmaps in a single vec to give ownership of all bitmaps
let mut bitmaps = Vec::new();
bitmaps.push(Bitmap {w: 10, h: 10, x: 0, y: 0, pixels: &image::PIXELS});while *display loop with some display library* {
blitter_test(&mut fb, &mut bitmaps);
*your display lib display update function with buffer &fb.pixels*
}// For testing : moves a 10x10 square and prints a 4x4 pixel at the center of the screen
fn blitter_test(mut fb: &mut Framebuffer, bitmaps: &mut Vec) {
fb.clear_area(640, 10, 0, 0, 0).unwrap();
bitmaps[0].blit(&mut fb).unwrap(); //copies a bitmap to the framebuffer
if bitmaps[0].x < WIDTH - 10 { bitmaps[0].x = bitmaps[0].x+3; } else { fb.clear(0); }
fb.draw_fatpixel(320,240,4,0xffffffff).unwrap();
}
```You can also view and run some (very basic) examples using the [minifb library](https://crates.io/crates/minifb) in the 'examples' directory:
```
cargo run --example demo --features="png-decode"
cargo run --example minifb --features="png-decode"
cargo run --example square
```[]
License: MIT