Inkscape has blend modes: Normal, Multiply, Screen, Darken, Lighten.
How could I know the algorithms for the blending modes in Inkscape per pixel?
For example, if we discuss a blending mode in Gimp, its manual provides description and mathematical formulas.
Top
Exact algorithms for blend modes
Re: Exact algorithms for blend modes
Hi.
Good call, compositing is the basic of the rendering.
By a quick search I found this.
Good call, compositing is the basic of the rendering.
By a quick search I found this.
multiply
The source color is multiplied by the destination color and replaces the destination. The resultant color is always at least as dark as either the source or destination color. Multiplying any color with black results in black. Multiplying any color with white preserves the original color.
f(Sc,Dc) = Sc × Dc
X = 1
Y = 1
Z = 1
Dca' = Sca × Dca + Sca × (1 - Da) + Dca × (1 - Sa)
Da' = Sa × Da + Sa × (1 - Da) + Da × (1 - Sa)
= Sa + Da - Sa × Da
screen
The source and destination colors are complemented, multiplied and the resultant color replaces the destination. The resultant color is always at least as light as either the source or destination colour. Screening any color with white results in white. Screening any color with black preserves the original color.
f(Sc,Dc) = Sc + Dc - (Sc × Dc)
X = 1
Y = 1
Z = 1
Dca' = (Sca × Da + Dca × Sa - Sca × Dca) + Sca × (1 - Da) + Dca × (1 - Sa)
= Sca + Dca - Sca × Dca
Da' = Sa + Da - Sa × Da
darken
The resultant color is the darker of source or destination colors. If the source is darker, it replaces the destination. Otherwise, the destination is preserved.
f(Sc,Dc) = min(Sc,Dc)
X = 1
Y = 1
Z = 1
Dca' = min(Sca × Da, Dca × Sa) + Sca × (1 - Da) + Dca × (1 - Sa)
Da' = Sa + Da - Sa × Da
or
if Sca × Da < Dca × Sa
src-over()
otherwise
dst-over()
lighten
The resultant color is the lighter of source or destination colors. If the source is lighter, it replaces the destination. Otherwise, the destination is preserved.
f(Sc,Dc) = max(Sc,Dc)
X = 1
Y = 1
Z = 1
Dca' = max(Sca × Da, Dca × Sa) + Sca × (1 - Da) + Dca × (1 - Sa)
Da' = Sa + Da - Sa × Da
or
if Sca × Da > Dca × Sa
src-over()
otherwise
dst-over()
Re: Exact algorithms for blend modes
So Gimp's and Inkscape's blend modes have the same names but different mathematical algorithms.
Right ?
Re: Exact algorithms for blend modes
Haven't gone through the details myself. Inkscape uses the svg specs&cairo. I'd expect the same behave.