PintaProject / Pinta

Simple GTK# Paint Program
http://www.pinta-project.com/
MIT License
1.74k stars 267 forks source link

Fix Move Selected Pixels tool for layers with transparency and nonstandard blend modes #820

Closed logiclrd closed 1 month ago

logiclrd commented 1 month ago

This PR fixes the semantics of the Move Selected Pixels tool so that the pixels that are being relocated within their layer do not get the layer's Opacity and BlendMode baked into them -- and thus reapplied when the move operation is committed.

I'm pretty sure this is the right thing to do. See issue #819.

I'm not sure if this is the right way to do it. I'm not all that familiar with the codebase. :-) It seems to fix it for me, though.

The one thing is that the selection layer ends up floating above the selected layer with 100% opacity until the move is committed. It would be even better if the selection appeared as though already merged into the selected layer -- so, with respect to the selected layer, it's 100% opaque, but with respect to the rest of the image, it is respecting the selected layer's opacity/blend mode.

Before committing the move:

image

After committing the move:

image

Notice that the part of the moved pixels that extends into the hole it left behind isn't now 25% opacity, it matches the rest of the image. And, the pixels that were moved on top of the rest of the layer (e.g. partially covering the curly red feature) simply replace them, instead of being blended with them.

logiclrd commented 1 month ago

The commit that this PR was originally made on inadvertently contained some whitespace changes to the comment block at the top. I didn't notice that Visual Studio Code was automatically deleting those spaces on save! In any case, I have fixed that.

logiclrd commented 1 month ago

Hmm, it occurs to me that the same issue might still arise with an image where the pixels themselves are not fully-opaque, rather than the layer opacity being less than 100%. This might not actually fix the issue properly. I think properly fixing this may require special-casing the blending of the selection layer.

logiclrd commented 1 month ago

Yep, confirmed. Will update #819 with further details.