2 releases
0.1.1 | Jun 15, 2022 |
---|---|
0.1.0 | Jun 15, 2022 |
#1014 in Embedded development
579 downloads per month
Used in stackblur-iter
10KB
116 lines
blend-srgb
is a small, #![no_std]
-compatible sRGB conversion and blending
library designed for performance.
It provides a small number of helper functions for converting and blending sRGB values. See the documentation for more details.
lib.rs
:
blend-srgb
is a small, #![no_std]
-compatible sRGB conversion and
blending library designed for performance.
It provides a small number of helper functions for converting and blending sRGB values:
srgb_to_rgb
, which converts a floating-point sRGB component to a floating-point Linear RGB component.rgb_to_srgb
which does the reverse.srgb8_to_rgb12
which converts an 8-bit sRGB component to a 12-bit Linear RGB component.rgb12_to_srgb8
which does the reverse.rgb12_to_srgb8_unchecked
which does not truncate the input to 12 bits.blend_srgb8_channel
which blends an sRGB foreground and background color with the provided alpha.blend_srgb8
which does the same as above but for (r, g, b) tuples.
Additionally, these functions are designed to be performant enough to be used in software composition pipelines. To facilitate this, a small (4.5k) lookup table is included. The lookup table can be small due to the usage of 12-bit linear values rather than 16-bit. 12 bits are enough to store all 8-bit sRGB values in linear space.
All functions other than srgb_to_rgb
and rgb_to_srgb
use only
integer operations, and are therefore fully compatible with #![no_std]
.
To activate #![no_std]
, just deactivate the std
feature. To keep
the floating-point methods, also add the libm
feature.
Dependencies
~98KB