doterax / guetzli-cuda-opencl

Perceptual JPEG encoder, optimized with CUDA&OpenCL, full JPEG format support.
Apache License 2.0
34 stars 4 forks source link

Add parameter --blend-on-white #4

Closed doterax closed 3 years ago

doterax commented 3 years ago
inline uint8_t BlendOnWhite(const uint8_t val, const uint8_t alpha) {
if (alpha < 1) return 255 - ((static_cast(val) * static_cast(alpha) + 128) / 255);
return val;
}

Code and idea from https://github.com/google/guetzli/issues/184