知识卡片
行主序渲染写入切片
把图像存为连续字节时,每行占宽度个元素,因此行 r、列 c 的下标是 r×宽+c。接收 &mut [u8] 的渲染器只需要调用方借出的区域。约束长度等于宽乘高以后,整图或水平带区都能调用同一渲染器。
关联阅读:[[像素轴映射复平面]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- A Tour of Rust 通过可变切片写行主序图像 · 查看原书依据
Think of a slice as an array or vector; pixels will refer to a slab of contiguous memory, typically millions of u8 bytes.
参考来源
- 位置:《Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)》第01章《A Tour of Rust》|通过可变切片写行主序图像,来源项目 `book-source`,`extracted/Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)/_epub-src/OEBPS/ch01.xhtml#plotting-the-set`
- 结论依据:原文渲染示例按行列写入借来的连续内存,并检查缓冲长度。
- 原始内容:Think of a slice as an array or vector; pixels will refer to a slab of contiguous memory, typically millions of u8 bytes.