知识卡片
PNG写入借用像素
内存中的像素交给 PNG 编码器时,可通过 &[u8] 借出缓冲区。编码器还需要宽、高和字节解释方式,ExtendedColorType::L8 表示一个字节一格灰度。文件写好后的有用产出在磁盘,返回 Ok(()) 仍能表达执行成功。
关联阅读:[[行主序渲染写入切片]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- A Tour of Rust 把成功值或 I/O 错误向上传递 · 查看原书依据
The write_image method is provided by the image::ImageEncoder trait, which we import on the first line of the example. We pass the encoder
参考来源
- 位置:《Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)》第01章《A Tour of Rust》|把成功值或 I/O 错误向上传递,来源项目 `book-source`,`extracted/Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)/_epub-src/OEBPS/ch01.xhtml#writing-image-files`
- 结论依据:原文展示图像尺寸和 L8 如何确定字节解释,成功值用单元类型。
- 原始内容:The write_image method is provided by the image::ImageEncoder trait, which we import on the first line of the example. We pass the encoder