On 9/15/06, David Gowers <00ai99@xxxxxxxxx> wrote:
Someone broke the undo grouping in CVS gimp. The attached plugin provides 'layer to selection' and 'image to selection' functionality. 'layer to selection' has one image.undo_group_start() but two image.undo_group_end()s. This is because of the mentioned breakage: someone has made it so that I need to do two undo_group_end()s for each undo_group_start(). All my other plugins depending on undo groups broke too.
On 9/15/06, William Skaggs < weskaggs@xxxxxxxxxxxxxxxxxxx> wrote:
From: Alexander Rabtchevich <alexander.v.rabtchevich@xxxxxxxxxxxxxxx>
>Some plug-ins (edge detection for example) provide images as a result.
>If their result is required as a selection, I new only one way to make
>it: create layer mask, copy the image into the mask and convert the mask
>into selection. Is there a shorter way to do it?
>
>More common question: maybe it worth improving such plug-ins with an
>option "Create selection"?
I don't think so, but it might be nice to have a "layer to selection"
filter that would create a selection from the gray values of the
active layer.
-- Bill
Someone broke the undo grouping in CVS gimp. The attached plugin provides 'layer to selection' and 'image to selection' functionality. 'layer to selection' has one image.undo_group_start() but two image.undo_group_end()s. This is because of the mentioned breakage: someone has made it so that I need to do two undo_group_end()s for each undo_group_start(). All my other plugins depending on undo groups broke too.
#!/usr/bin/python import gimp,gimpplugin from gimpfu import PLUGIN, PF_INT, PF_IMAGE, PF_DRAWABLE, CHANNEL_OP_INTERSECT, CHANNEL_OP_REPLACE, FOREGROUND_FILL, GRAY_CHANNEL pdb = gimp.pdb import os class LayerToSelection(gimpplugin.plugin): def query(self): author = 'David Gowers <00ai99@xxxxxxxxx>' date = '2006' gimp.install_procedure('plug_in_layer_to_selection', 'Convert the greyscale values of a layer or channel to a selection', '', author, date, author, '<Image>/Layer/To S_election', '*', PLUGIN, [(PF_INT, 'run_mode', "run mode"),(PF_IMAGE, 'image', 'Image'), (PF_DRAWABLE, 'drawable', 'Drawable')], []) gimp.install_procedure('plug_in_image_to_selection', 'Convert the greyscale values of an image to a selection', '', author, date, author, '<Image>/Image/To S_election', '*', PLUGIN, [(PF_INT, 'run_mode', "run mode"),(PF_IMAGE, 'image', 'Image'), (PF_DRAWABLE, 'drawable', 'Drawable')], []) def plug_in_layer_to_selection(self, run_mode, image, drawable): bufname = 'TEMP LAYER2SELECTION' try: tmp = drawable.color #easy -- load a channel pdb.gimp_selection_load(drawable) except: image.undo_group_start() pdb.gimp_selection_none(image) buf = pdb.gimp_edit_named_copy(drawable, bufname) c = pdb.gimp_channel_new(image, image.width, image.height, bufname, 50.0, (0,0,0)) image.add_channel(c) fsel = pdb.gimp_edit_named_paste(c, buf, False) pdb.gimp_floating_sel_anchor(fsel) pdb.gimp_selection_load(c) image.remove_channel(c) image.undo_group_end() image.undo_group_end() # This is wrong, but someone B0rked the undo grouping in recent CVS. # all my other plugins that use undo grouping are broken too because they do not have this # extra undo_group_end() def plug_in_image_to_selection(self, run_mode, image, drawable): c = pdb.gimp_channel_new_from_component(image, GRAY_CHANNEL, 'TEMP IMAGE2SELECTION') pdb.gimp_selection_load(c) gimp.delete(c) def start(self): gimpplugin.plugin.start(self) if __name__ == '__main__': LayerToSelection().start()
_______________________________________________ Gimp-developer mailing list Gimp-developer@xxxxxxxxxxxxxxxxxxxxxx https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer