Expand description
Draw sprites quickly using bitwise operations and a masking color.
Usage
This crate is on crates.io and can be used by adding
blit
to the dependencies in your project’s Cargo.toml
.
[dependencies]
blit = "0.5"
and this to your crate root:
extern crate blit;
Examples
ⓘ
extern crate image;
const WIDTH: usize = 180;
const HEIGHT: usize = 180;
const MASK_COLOR: u32 = 0xFF00FF;
let mut buffer: Vec<u32> = vec![0xFFFFFFFF; WIDTH * HEIGHT];
let img = image::open("examples/smiley.png").unwrap();
let img_rgb = img.as_rgb8().unwrap();
// Blit directly to the buffer
let pos = (0, 0);
img_rgb.blit(&mut buffer, WIDTH, pos, Color::from_u32(MASK_COLOR));
// Blit by creating a special blitting buffer first, this has some initial
// overhead but is a lot faster after multiple calls
let blit_buffer = img_rgb.to_blit_buffer(Color::from_u32(MASK_COLOR));
let pos = (10, 10);
blit_buffer.blit(&mut buffer, WIDTH, pos);
let pos = (20, 20);
blit_buffer.blit(&mut buffer, WIDTH, pos);
// Save the blit buffer to a file
blit_buffer.save("smiley.blit");
Re-exports
pub use image_feature::*;
pub use aseprite_feature::*;
Modules
Structs
A data structure holding a color and a mask buffer to make blitting on a buffer real fast.
A newtype representing the color in a buffer.
Traits
A trait adding blitting functions to image types.