summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJasper van de Gronde <jasper.vandegronde@gmail.com>2012-10-27 12:42:19 +0000
committerJasper van de Gronde <th.v.d.gronde@hccnet.nl>2012-10-27 12:42:19 +0000
commite920c0f97739a936d6e02f4cc6a4feb8486f683e (patch)
tree760e2c05a6f1a4478e0fd75ab14d153e49fbbc90 /src
parentFix C++11 narrowing conversion errors (diff)
downloadinkscape-e920c0f97739a936d6e02f4cc6a4feb8486f683e.tar.gz
inkscape-e920c0f97739a936d6e02f4cc6a4feb8486f683e.zip
Clamp colour channels in feComposite result to alpha channel, instead of 1, as the channels are premultiplied.
(bzr r11835)
Diffstat (limited to 'src')
-rw-r--r--src/display/nr-filter-composite.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp
index b25ecdf2c..040424cb3 100644
--- a/src/display/nr-filter-composite.cpp
+++ b/src/display/nr-filter-composite.cpp
@@ -48,10 +48,11 @@ struct ComposeArithmetic {
gint32 go = _k1*ga*gb + _k2*ga + _k3*gb + _k4;
gint32 bo = _k1*ba*bb + _k2*ba + _k3*bb + _k4;
- ao = (pxclamp(ao, 0, 255*255*255) + (255*255/2)) / (255*255);
- ro = (pxclamp(ro, 0, 255*255*255) + (255*255/2)) / (255*255);
- go = (pxclamp(go, 0, 255*255*255) + (255*255/2)) / (255*255);
- bo = (pxclamp(bo, 0, 255*255*255) + (255*255/2)) / (255*255);
+ ao = pxclamp(ao, 0, 255*255*255); // r, g and b are premultiplied, so should be clamped to the alpha channel
+ ro = (pxclamp(ro, 0, ao) + (255*255/2)) / (255*255);
+ go = (pxclamp(go, 0, ao) + (255*255/2)) / (255*255);
+ bo = (pxclamp(bo, 0, ao) + (255*255/2)) / (255*255);
+ ao = (ao + (255*255/2)) / (255*255);
ASSEMBLE_ARGB32(pxout, ao, ro, go, bo)
return pxout;