toUnsigned

Convert floating point input to unsigned.

Slice!(ReturnType*, dims)
toUnsigned
(
ReturnType = ubyte
InputType
size_t dims
)
(
Slice!(InputType*, dims) input
)

Examples

1 import std.math : approxEqual;
2 import mir.ndslice : sliced;
3 
4 // dfmt off
5 Slice!(double*, 3) rgb = [
6     1.0, 0.0, 0.0,
7     0.0, 1.0, 0.0,
8     0.0, 0.0, 1.0,
9     0.470588, 0.470588, 0.470588
10 ].sliced(4, 1, 3);
11 
12 ubyte[] rgbU = [
13     255, 0, 0,
14     0, 255, 0,
15     0, 0, 255,
16     120, 120, 120
17 ];
18 Slice!(ubyte*, 3) rgbUnsigned = rgbU.sliced(4, 1, 3);
19 //dfmt on
20 
21 assert(approxEqual(rgb.toUnsigned, rgbUnsigned));

Meta