GNOME Bugzilla – Bug 70964
Gradient Map ignores alpha channel from source layer
Last modified: 2009-08-15 18:40:50 UTC
The Gradient Map plug-in (Filters->Colors->Map->Gradient Map) ignores the alpha channel and resets it so that the layer becomes fully opaque after applying the filter, even if it was fully transparent before. It should preserve the alpha channel instead of resetting it.
The following patch fixes the problem by multiplying the samples from the gradient (which may have an alpha channel) with the previous alpha value of the source pixel. Previously, the source alpha was implicitely assumed to be 100% (255), which is incorrect.
Created attachment 6651 [details] [review] patch for plug-ins/common/gradmap.c
Two minor corrections: - In my previous comment, my explanation is not correct: I wrote that the patch multiplies the samples from the gradient with the alpha value of the source layer. Instead, I should have said that it multiplies the alpha value from the gradient with the one from the source layer. This is what the patch does, and this is correct. - In the patch, maybe it would be better to cast samp[b] and src[b] to (guint) instead of (gint). This does not change much, but this is a bit cleaner and maybe even a bit more efficient. Please apply this patch to the 1.2 branch and to HEAD.
Shouldn't that be dest[b] = ((guint)(samp[b]) * (guint)(src[b])) / 256; instead?
My last comment was bogus. I have applied the patch (with the cast changed to guint) to the stable and development branches.
Fix is part of gimp-1.2.3, which has just been released. Bug is now CLOSED.