GNOME Bugzilla – Bug 170707
Implement Edit->Fade
Last modified: 2006-10-21 18:47:00 UTC
A popular feature of another image editing program is the ability to "fade" the most recent manipulation, by creating a blend between the current state of a layer and its previous state. I have put together an implementation of this, whose code is attached below. It inserts a "Fade XXX" entry into the image Edit menu, where XXX is the same thing shown for "Undo". Currently all operations that generate an undo of type GIMP_DRAWABLE_UNDO can be faded, but it should be possible to extend it to handle paint and ink operations as well. Selecting Edit->Fade brings up a modal dialog, whose only control is an opacity slider. It comes up initially with opacity 100, which corresponds to the current state. Lowering the opacity to 0 changes the drawable to its previous state. Intermediate values produce a mixture of the two. There are a few issues worth mentioning: 1) For some reason, the function mishandles the blue channel of the background layer of an RGB image. I haven't yet been able to figure out why. It gets everything else right as far as I can tell. 2) Cancelling the fade operation leaves an entry on the Redo stack. I need to figure out how to remove this. 3) The current implementation acts on the whole affected drawable, even if the undo only applies to part of the drawable. So, it ought to be made more efficient.
Created attachment 38860 [details] [review] diff against HEAD implementing Edit->Fade The important stuff is in the new file dialogs/fade-undo-dialog.c. Everything else is cruft and menu-handling.
*** Bug 120033 has been marked as a duplicate of this bug. ***
The important stuff should be in the core, not in app/dialogs. But it should be easy to move the core functionality where it belongs. I'd like to get Mitch's comment on this implementation.
One of the cool thing about this feature in the other IMP is that it allows to use Blend Modes (layer modes), as briefly noted in http://bugzilla.gnome.org/show_bug.cgi?id=120033 .
*** Bug 170759 has been marked as a duplicate of this bug. ***
In order to do this properly, we would have to push the replacing pixels to the undo stack, not only the replaced pixels. This would increase memory requirements for the Undo stack but I think that's acceptable. If we do this, it would also become easy to implement the undo brush requested in bug #74554.
Well, that would be a pretty substantial change, wouldn't it? I think it would be pretty simple to implement gimp_image_undo_fade() in the core -- in gimpimage-undo.c? -- with a "mode" argument, and do it that way. Not as elegant, but functional. Would that be worth doing?
I have hacked a bit on your patch, in the direction of what sven said. Will attach the modified patch tomorrow.
I won't discourage this. It is just that while thinking about how to implement this, I came to a different way to implement it, so I will mention my idea here just in case it may look more simple (#6 talks aboutmemory consuption on this method). basically, what I thought would require an "undo/redo" API, and be doable by a simple plug-in. By undo/redo API, I mean a simple libgimp/PDB call to undo the last action (and another to redo, but it would not be used here). The fade plug-in them would just: copy the active drawable, undo the last action, paste the copy as a new layer, set its opacity, and merge both new layer and previously active drawable. Regards!
Mitch, could you follow up on comment #8? (If you've changed your mind, that's fine).
Since we will want to have preview on this feature, it should probably become an imagemap tool. But first the changes to the undo stack will have to be figured out.
This is probably too sensitive to get into 2.4, so I am bumping the target to Future, althought that's a bit of a shame given the potential usability value of the feature.
Upgrading target from Future to 2.6.
Created attachment 75086 [details] [review] New patch using GimpDrawableUndo New patch allows to change opacity and paint mode, by using the new GimpDrawableUndo.
Created attachment 75087 [details] fade-dialog.c
Created attachment 75088 [details] fade-dialog.h
Created attachment 75089 [details] [review] Add missing help ID
2006-10-21 Michael Natterer <mitch@gimp.org> Added "Edit -> Fade" which allows to modify the paint mode and opacity of the last drawable operation (fill, plugins etc.). Started from a patch by Bill Skaggs. Fixes bug #170707. * app/base/base-enums.[ch] (enum GimpLayerModeEffects): register the values REPLACE_MODE, ERASE_MODE and ANTI_ERASE_MODE with the type system. * app/widgets/gimppropwidgets.[ch] * app/widgets/gimpwidgets-constructors.[ch]: added "gboolean with_replace_modes" to the paint mode menu constructors. * app/tools/gimppaintoptions-gui.c * app/widgets/gimpbrushselect.c * app/widgets/gimplayertreeview.c: pass with_replace_modes = FALSE. * app/core/gimpdrawableundo.[ch]: added members which keep tiles, paint mode and opacity of the pasted pixels. * app/core/gimpimage-undo.[ch] (gimp_image_undo_get_fadeable): returns a GimpUndo suitable for a fade operation, or NULL. * app/core/gimp-edit.[ch] (gimp_edit_fade): implements the actual fade by undoing the last operation and then re-applying the pixels with different paint mode and opacity. * app/core/gimpdrawable-combine.c: store the pasted pixels in the GimpDrawableUndo. * app/actions/edit-actions.c * app/actions/edit-commands.[ch]: action and callback for fade. * app/dialogs/Makefile.am * app/dialogs/fade-dialog.[ch]: the fade dialog. * app/widgets/gimphelp-ids.h: the fade help ID. * menus/image-menu.xml.in: added a menu entry in "Edit".