RSS/Atom feed Twitter
Site is read-only, email is disabled

copy-paste: position shift with alpha images

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

8 of 11 messages available
Toggle history

Please log in to manage your subscriptions.

copy-paste: position shift with alpha images Martin Bernreuther 30 Oct 22:51
  copy-paste: position shift with alpha images Sven Neumann 31 Oct 10:12
MartinBern@web.de 07 Oct 20:21
  copy-paste: position shift with alpha images Jeff Trefftzs 31 Oct 00:31
   copy-paste: position shift with alpha images Sven Neumann 31 Oct 10:17
  script-fu-scheme: Full implementation of Scheme? Jeff Trefftzs 31 Oct 00:41
sven@gimp.org 07 Oct 20:21
  copy-paste: position shift with alpha images Jeff Trefftzs 31 Oct 18:29
   copy-paste: position shift with alpha images Sven Neumann 31 Oct 18:36
200210311852.g9VIqGp02230@t... 07 Oct 20:21
  copy-paste: position shift with alpha images Sven Neumann 31 Oct 20:35
Martin Bernreuther
2002-10-30 22:51:11 UTC (over 21 years ago)

copy-paste: position shift with alpha images

Hello,

I just wantet to copy a rectangle area from a source-layer to a target layer of an image. That's what I done first:

(gimp-rect-select image 0 0 layer-width height REPLACE FALSE 0) (gimp-edit-copy source-layer)
(let ((floating-sel (car (gimp-edit-paste target-layer FALSE)))) (gimp-floating-sel-anchor floating-sel))

This works for a lot of cases BUT if I have an image showing a figure on a transparent background (with alpha channel), something strange happens: The position of the figure on the target-layer is shifted (an the only the figure itself is selected) It only works if the bounding box of the visible parts equal the selection. I got the same results using the GUI (also with select-all).

How can I avoid this?

Is there a faster way to transfer the layer contents to another layer, avoiding the intermediate step of the buffer?

Thanks Martin

Jeff Trefftzs
2002-10-31 00:31:58 UTC (over 21 years ago)

copy-paste: position shift with alpha images

Hi Martin -

First, your questions would be better directed to the gimp-user (instead of gimp-developer) list. And I can also recommend the script-fu group on yahoo.

To answer your question: you can avoid creating the intermediate variable by doing
(gimp-floating-sel-anchor
(car (gimp-edit-paste target-layer FALSE)))

To ensure that your selection winds up in the same place in the new layer, try (if you can)
making sure that the layer from which you get your selection is the same size as the image, using (perl-fu-layer-to-image-size 1) . This works on the active layer only, and may not work on windows systems lacking perl-fu support.

HTH,

Jeff Trefftzs
2002-10-31 00:41:43 UTC (over 21 years ago)

script-fu-scheme: Full implementation of Scheme?

I've posted the siod documentation that I use on my website at

http://trefftzs.topcities.com/siod.html

It also shows functions that are not available in the Gimp, but fewer than your source. I seem to remember that I had to roll my own floor, ceil, and round functions.

Good luck.

Sven Neumann
2002-10-31 10:12:13 UTC (over 21 years ago)

copy-paste: position shift with alpha images

Hi,

Martin Bernreuther writes:

I just wantet to copy a rectangle area from a source-layer to a target layer of an image. That's what I done first:

(gimp-rect-select image 0 0 layer-width height REPLACE FALSE 0) (gimp-edit-copy source-layer)
(let ((floating-sel (car (gimp-edit-paste target-layer FALSE)))) (gimp-floating-sel-anchor floating-sel))

This works for a lot of cases BUT if I have an image showing a figure on a transparent background (with alpha channel), something strange happens: The position of the figure on the target-layer is shifted (an the only the figure itself is selected) It only works if the bounding box of the visible parts equal the selection. I got the same results using the GUI (also with select-all).

the internal clipboard automatically crops the stored selection.

How can I avoid this?

Is there a faster way to transfer the layer contents to another layer, avoiding the intermediate step of the buffer?

you could copy the whole layer using (gimp-layer-copy).

Salut, Sven

Sven Neumann
2002-10-31 10:17:51 UTC (over 21 years ago)

copy-paste: position shift with alpha images

Hi,

Jeff Trefftzs writes:

making sure that the layer from which you get your selection is the same size as the image, using (perl-fu-layer-to-image-size 1) . This works on the active layer only, and may not work on windows systems lacking perl-fu support.

oh, come on. calling perl to resize the layer to the image size is a bit of an overkill if it can also be done in one or two lines of scheme. The following code is untested, but might actually work:

(gimp-layer-resize layer (car (gimp-image-width image)) (car (gimp-image-height image)) (- (car (gimp-layer-offsets layer))) (- (cadr (gimp-layer-offsets layer))))

Salut, Sven

Jeff Trefftzs
2002-10-31 18:29:05 UTC (over 21 years ago)

copy-paste: position shift with alpha images

Sven wrote:

oh, come on. calling perl to resize the layer to the image size is a bit of an overkill if it can also be done in one or two lines of scheme. The following code is untested, but might actually work: ...

It may be overkill, but it's available from the layers & channels dialog box in the right-click menu, so I assumed that's how it was supposed to be done. Should we replace the menu entry with a call to your scheme function instead?

Sven Neumann
2002-10-31 18:36:52 UTC (over 21 years ago)

copy-paste: position shift with alpha images

Hi,

Jeff Trefftzs writes:

oh, come on. calling perl to resize the layer to the image size is a bit of an overkill if it can also be done in one or two lines of scheme. The following code is untested, but might actually work: ...

It may be overkill, but it's available from the layers & channels dialog box in the right-click menu, so I assumed that's how it was supposed to be done.

that menu entry points to layer_resize_to_image() in app/layers.c.

Salut, Sven

Sven Neumann
2002-10-31 20:35:01 UTC (over 21 years ago)

copy-paste: position shift with alpha images

Hi,

Jeff Trefftzs writes:

that menu entry points to layer_resize_to_image() in app/layers.c.

Aha! I didn't see a reference to it in the PDB explorer, so I thought the perl-fu function was what was used. Should I file a bug report? At any rate, I couldn't find it in the PDB.

it's not in the PDB since it was added late and it can be easily accomplished thru the PDB as it is. Please file a bug-report if you think we should add it. Chances that it will be added increase significantly if you attach a patch. Such a patch would probably only have to change the file tools/pdbgen/pdb/layer.pdb.

Salut, Sven