1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//! An opinionated in-memory buffer for image data.
//!
//! # General Usage
//!
//! Let us start by creating a simple RgbA buffer. For this we need to:
//!
//! 1. Specify the texel type with the right depth and channels.
//! 2. Define the layout, a plain matrix with width and height
//! 3. Allocate the frame with the layout
//!
//! [1]: https://crates.io/crates/rgb
//! [2]: https://crates.io/crates/palette
//!
//! ```
//! use image_canvas::Canvas;
//! use image_canvas::layout::{CanvasLayout, SampleParts, Texel};
//!
//! // Define what type of color we want to store...
//! let texel = Texel::new_u8(SampleParts::RgbA);
//! // and which dimensions to use, chooses a stride for us.
//! let layout = CanvasLayout::with_texel(&texel, 32, 32)?;
//!
//! let frame = Canvas::new(layout);
//! # use image_canvas::layout::LayoutError;
//! # Ok::<(), LayoutError>(())
//! ```
//!
//! Converting to a different color is also possible:
//! 1. Explicitly assign a fitting `Color` to source and target
//! 2. Call the conversion method.
//!
//! ```
//! use image_canvas::Canvas;
//! use image_canvas::color::Color;
//! use image_canvas::layout::{CanvasLayout, SampleParts, Texel};
//!
//! let layout = CanvasLayout::with_texel(&Texel::new_u8(SampleParts::Lab), 32, 32)?;
//! let mut from = Canvas::new(layout.clone());
//! from.set_color(Color::Oklab)?;
//!
//! let layout = CanvasLayout::with_texel(&Texel::new_u8(SampleParts::Rgb), 32, 32)?;
//! let mut into = Canvas::new(layout);
//! into.set_color(Color::SRGB)?;
//!
//! // … omitted: some pixel initialization
//! from.convert(&mut into);
//!
//!// Now read the sRGB frame, e.g. to initialize an HTTP canvas
//! into.as_bytes();
//!
//! # use image_canvas::layout::LayoutError;
//! # Ok::<(), LayoutError>(())
//! ```
// Deny, not forbid, unsafe code. In `arch` module we have inherently unsafe code, for the moment.
// Maybe at a future point we gain some possibility to write such code safely.
// Be std for doctests, avoids a weird warning about missing allocator.
extern crate std;
extern crate alloc;
/// Putting it all together with a buffer type.
/// The main frame module.
/// The layout implementation, builders, descriptors.
/// Conversion operation.
pub use ;
pub use ;
pub use ;