app: fix legacy divide blend mode

The porting from 8bit per component scaled some 8bit fractions up to huge
floating point numbers, this works for most values but causes trouble for near
transparent pixel values. This commit copies the inner blend loop from the new
divide layer mode, but keeps the old compositing logic.
This commit is contained in:
Øyvind Kolås
2017-01-24 18:36:08 +01:00
parent 9128f3fc87
commit 6a1d49bc6d

View File

@ -88,7 +88,15 @@ gimp_operation_divide_legacy_process (GeglOperation *op,
for (b = RED; b < ALPHA; b++)
{
gfloat comp = (4294967296.0 / 4294967295.0 * in[b]) / (1.0 / 4294967295.0 + layer[b]);
gfloat comp = in[b] / layer[b];
/* make infinities(or NaN) correspond to a high number,
* to get more predictable math, ideally higher than 5.0
* but it seems like some babl conversions might be
* acting up then
*/
if (!(comp > -42949672.0f && comp < 5.0f))
comp = 1.0f;
out[b] = comp * ratio + in[b] * (1.0 - ratio);
out[b] = CLAMP (out[b], 0.0, 1.0);