Quoting Rob Antonishen <rob.antonis...@gmail.com>:
> I am writing a c plugin to scale a layer.  (This is much as an
> exercise for me as anything).
> I have looked at a few examples and they handle things differently....
> - Create a new image with a new layer the new size

The only reason I can conceive why this might be desirable is if the  
image is Indexed (and RGB scaling is desired); and then you must  
decide how the rescaled layer is to be re-converted back to Indexed.

> - Create a new layer in the existing image just above the input layer

I'm not much of a fan of scripts/plug-ins which merely combine two  
operations into one. Running a "dup-scale" command is hardly a  
sufficient improvement to duplicating the layer and scaling the  
duplicate. (The exception to this being if a user wishes to assign a  
keyboard shortcut to that single command, but this is most dependent  
upon the use case and is best left to customized, one-off scripts.)

> - Create a new layer in the existing image just above the input layer
> and delete the input layer

Under normal scenarios, this produces the result I should expect,  
effectively scaling the layer; however, it raises some implementation  
and behavioral issues should the active layer be in the floated state.

Furthermore, this approach has the unfortunate side effect of changing  
the layer's ID (and less importantly, its tattoo). A filter should  
avoid changing a layer's ID *if possible* as this facilitates other  
scripts/plug-ins being able to use the filter and in some cases permits.

> - Initialize the input pixel region then change the input layer's size
> and push the output pixel region into the resized input layer
> - change the image canvass to match the resized layer?

This seems to me the approach that should be pursued as it would  
appear to work with floated layers and doesn't unnecessarily modify  
the layer's ID.

Quoting Rob Antonishen <rob.antonis...@gmail.com>:

> The "built-in" scaling options are:
>  Layer->Scale Layer which scales the active layer only but does not
> change the image canvas size or scale the associated layer mask (is
> that a reasonable behavior?).

"Layer->Scale Layer" (in the Menus) indeed scales the associated  
layermask. Currently, I believe all PDB layer transformations also  
likewise operate upon the associated layermask (this was not always  
the case).

>  - should an action like scaling scale all layers, masks, channels
> and paths of an image if it is the image menu (otherwise in the layer
> menu)? (I'm leaning towards yes)

Yes. Commands in the Image Menu should operate on the image as a whole.

>  - should an action like scaling a layer also scale an associated
> layer mask? (yes?)

It has been my experience that having a layermask with different  
dimensions then the layer with which it's associated can lead to  
catastrophic problems in GIMP. I would highly advise that directly  
after changing the dimensions of a layer, its layermask's dimensions  
be adjusted to match.

Gimp-developer mailing list

Reply via email to