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

no-std simple-blit

提供从一种表面到另一种表面进行简单位块传输以及一些可能的转换

13 个版本 (3 个稳定版本)

2.0.0 2024 年 6 月 9 日
1.2.0 2024 年 6 月 9 日
1.0.0 2024 年 2 月 20 日
0.8.0 2024 年 1 月 16 日
0.3.0 2023 年 11 月 14 日

#70无标准库

Download history 13/week @ 2024-05-27 249/week @ 2024-06-03 107/week @ 2024-06-10 70/week @ 2024-07-22

每月 70 次下载
2 crates 中使用

MIT-0 许可证

31KB
778

simple-blit

提供从一种表面到另一种表面进行简单位块传输以及一些可能的转换。

示例

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
    GenericSurface::new(&mut dest, size(5, 5))
        .unwrap()
        // offset on the destination
        .offset_surface_mut(point(1, 1)),
    // you can borrow the surface if you don't want to drop it
    // (the destination has to be borrowed mutably of course)
    &GenericSurface::new(&src, size(4, 4))
        .unwrap()
        .sub_surface(
            point(0, 0), // source offset
            size(3, 3)   // size of the area to copy
        ),
    // 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 功能

  • pixels-integration (默认关闭): 为 Pixels 实现 SurfaceSurfaceMut
  • image-integration (默认关闭): 为 ImageSurface 实现 SurfaceSurfaceMut
  • serde (默认关闭): 为表面类型和 Transform 实现 SerializeDeserialize

许可证

自版本 1.0.0 以来,此 crate 的许可证已从 MIT 更改为 MIT-0(也称为 MIT 无贡献)。

依赖项

~0–31MB
~462K SLoC