#blit #pixel #blitting #no-alloc #width-height

no-std simple-blit

Provides simple blitting from one surface to another with some possible transformations

11 releases (1 stable)

1.0.0 Feb 20, 2024
0.8.0 Jan 16, 2024
0.7.1 Jan 5, 2024
0.6.1 Dec 27, 2023
0.3.0 Nov 14, 2023

#88 in No standard library


Used in 2 crates

MIT-0 license

26KB
639 lines

simple-blit

Provides simple blitting from one surface to another with some possible transformations.

Example

use simple_blit::*;

let mut dest: [u8; 25] = [
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
];

let src: [u8; 16] = [
    1, 1, 1, 1,
    1, 1, 1, 1,
    1, 1, 1, 1,
    1, 1, 1, 1,
];

blit(
    // construct a surface which holds width and height
    &mut GenericSurface::new(&mut dest, size(5, 5)).unwrap(),
    // where to blit
    point(1, 1),
    &GenericSurface::new(&src, size(4, 4)).unwrap(),
    // where to blit from
    point(0, 0),
    // size of the area
    size(3, 3),
    // no transformations
    Default::default(),
);

assert_eq!(dest, [
    0, 0, 0, 0, 0,
    0, 1, 1, 1, 0,
    0, 1, 1, 1, 0,
    0, 1, 1, 1, 0,
    0, 0, 0, 0, 0,
]);

Cargo features

  • pixels-integration (off by default): implements Surface and SurfaceMut for Pixels.
  • image-integration (off by default): implements Surface and SurfaceMut for ImageSurface
  • serde (off by default): implements Serialize and Deserialize for surface types and Transform.

License

As of version 1.0.0, this crate's license has been changed from MIT to MIT-0 (aka MIT No Attribution).

Dependencies

~0–36MB
~446K SLoC