summaryrefslogtreecommitdiff
path: root/lib/jxl/alpha.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/jxl/alpha.cc')
-rw-r--r--lib/jxl/alpha.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/jxl/alpha.cc b/lib/jxl/alpha.cc
index 77ac902..f0ab39a 100644
--- a/lib/jxl/alpha.cc
+++ b/lib/jxl/alpha.cc
@@ -108,4 +108,13 @@ void UnpremultiplyAlpha(float* JXL_RESTRICT r, float* JXL_RESTRICT g,
}
}
+void UnpremultiplyAlpha(float* JXL_RESTRICT rgba, size_t num_pixels) {
+ for (size_t x = 0, ix = 0; x < num_pixels; ++x, ix += 4) {
+ const float multiplier = 1.f / std::max(kSmallAlpha, rgba[ix + 3]);
+ rgba[ix] *= multiplier;
+ rgba[ix + 1] *= multiplier;
+ rgba[ix + 2] *= multiplier;
+ }
+}
+
} // namespace jxl