Just released a new crate, `blend-srgb` which implements some handy sRGB conversion and blending functions

35 points LoganDark

For some reason I had trouble finding a library on crates.io that did this. I found a crate that converts 8-bit sRGB to floating-point, but that's slow and not really useful.

So enter blend-srgb, which offers:

  • Round-trippable conversions between 8-bit sRGB and 12-bit linear RGB using lookup tables
  • sRGB<->linear transfer functions in floating-point (just in case you need them)
  • an sRGB blending function (that right now unfortunately doesn't support transparency)

As a bonus, it has a #![no_std] mode that excludes the floating-point methods, and a libm feature that re-enables libm implementations of them.

Not really sure what to say other than that it exists now.

GitHub