GNOME Bugzilla – Bug 145373
Floating selection without alpha channel shows boundary at 50% blue
Last modified: 2005-09-08 19:39:25 UTC
I'm working on a plugin to support cut-and-paste of images using the Mac OS X system clipboard. (http://sf.net/projects/gimp-mac-helper/) In trying to mimic Gimp's internal cut-and-paste behavior, I'm attaching the pasted layer as a floating selection. When pasting images with alpha this works fine, but when creating a layer without an alpha channel to paste an opaque image, the marching ants boundary is incorrectly shown at the 50% threshold of the blue channel instead of around the layer's edge. This is probably due to an assumption that floating layers are always from internal pasting, that pasted buffers always have alpha (cf bug 134304), and thus that the last channel is always an alpha channel. I can work around this by always pasting with alpha, but it'd be nice if it weren't necessary.
Created attachment 29198 [details] Screenshot showing misplaced marching ants boundary
All layers but the background layer need to have an alpha channel. Where's the problem? BTW, since GIMP from CVS supports the system clipboard, it is questionable if your plug-in makes sense. It would be better to join the GIMP development and help to make the new clipboard work well with Mac OS X instead of adding an extra plug-in for it.
> All layers but the background layer need to have an alpha channel. Where's the > problem? Well, in that case it's rather surprising that I can create such a layer from a plugin. Shouldn't this error condition be detected?
IIRC, GIMP-1.2 used to add an alpha channel but IMO this is the wrong behaviour. GIMP should probably just reject such a layer to be added to the image's layer stack.
This one will be easily forgotten here on the 2.0.6 milestone. Moving to 2.2 instead.
Created attachment 39028 [details] [review] patch for app/core/gimpimage.c Here is a simple patch that rejects layers without alpha added at any position except 0. Seems to work okay, but probably will turn out to break one or two badly written scripts or plug-ins, so not suitable for the stable branch.
Comment on attachment 39028 [details] [review] patch for app/core/gimpimage.c Such a check must be done in the PDB wrappers. It is completely unacceptable for the application to use g_warning() in this case, since g_warning() indicates a programming error.
Fixed in CVS: 2005-09-08 Michael Natterer <mitch@gimp.org> * app/core/gimplayer-floating-sel.c (floating_sel_boundary): if the floating selection has no alpha, manually create BoundSegs of its outline instead of calling boundary_find() (which creates a boundary of the last channel). Fixes bug #145373. * app/widgets/gimplayertreeview.c (gimp_layer_tree_view_floating_selection_changed): update all layer names' text attributes, not only for layers with alpha. Fixes layer name display when making a new layer out of a floating selection without alpha.