mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-22 12:32:37 +00:00
New version of the script that works on a temporary copy of the image
2004-04-14 Raphael Quinet <quinet@gamers.org> * plug-ins/script-fu/scripts/copy-visible.scm: New version of the script that works on a temporary copy of the image instead of copying the visible layers. Fixes bug #139989.
This commit is contained in:
parent
62b8ae01e4
commit
ab5ffbb5be
|
@ -1,3 +1,9 @@
|
|||
2004-04-14 Raphaël Quinet <quinet@gamers.org>
|
||||
|
||||
* plug-ins/script-fu/scripts/copy-visible.scm: New version of the
|
||||
script that works on a temporary copy of the image instead of
|
||||
copying the visible layers. Fixes bug #139989.
|
||||
|
||||
2004-04-14 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/common/film.c: fixed typo (bug #140039).
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
; The GIMP -- an image manipulation program
|
||||
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
;
|
||||
; "Copy Visible" -- copy the visible selection so that it can be pasted easily
|
||||
; Copyright (C) 2004 Raphaël Quinet, Adrian Likins, Sven Neumann
|
||||
;
|
||||
; This program is free software; you can redistribute it and/or modify
|
||||
; it under the terms of the GNU General Public License as published by
|
||||
; the Free Software Foundation; either version 2 of the License, or
|
||||
|
@ -15,73 +18,58 @@
|
|||
; along with this program; if not, write to the Free Software
|
||||
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
;
|
||||
; 2004-04-14 This script was almost rewritten from scratch
|
||||
; by Raphaël Quinet <raphael@gimp.org>
|
||||
; see also http://bugzilla.gnome.org/show_bug.cgi?id=139989
|
||||
;
|
||||
; The code is new but the API is the same as in the previous version:
|
||||
; "Copy Visible" version 0.11 01/24/98
|
||||
; by Adrian Likins <adrian@gimp.org>
|
||||
; _heavily_ based on:
|
||||
; cyn-merge.scm version 0.02 10/10/97
|
||||
; Copyright (C) 1997 Sven Neumann (neumanns@uni-duesseldorf.de)
|
||||
;
|
||||
;
|
||||
|
||||
(define (script-fu-copy-visible image
|
||||
drawable)
|
||||
(let* ((layers (gimp-image-get-layers image))
|
||||
(define (script-fu-copy-visible orig-image
|
||||
drawable)
|
||||
(let* ((image (car (gimp-image-duplicate orig-image)))
|
||||
(layers (gimp-image-get-layers image))
|
||||
(num-layers (car layers))
|
||||
(num-visi-layers 0)
|
||||
(curlayer (car (gimp-image-get-active-layer image)))
|
||||
(num-visible-layers 0)
|
||||
(visible-layer -1)
|
||||
(layer-array (cadr layers)))
|
||||
|
||||
(if (= curlayer -1)
|
||||
(set! curlayer (car (gimp-image-get-active-channel image))))
|
||||
|
||||
(gimp-image-undo-group-start image)
|
||||
|
||||
; copy all visible layers and make them invisible
|
||||
(set! layer-count 1)
|
||||
(set! visi-array (cons-array num-layers))
|
||||
(while (<= layer-count num-layers)
|
||||
(set! layer (aref layer-array (- num-layers layer-count)))
|
||||
(aset visi-array (- num-layers layer-count)
|
||||
(car (gimp-drawable-get-visible layer)))
|
||||
(if (= TRUE (car (gimp-drawable-get-visible layer)))
|
||||
(begin
|
||||
(set! copy (car (gimp-layer-copy layer TRUE)))
|
||||
(gimp-image-add-layer image copy -1)
|
||||
(gimp-drawable-set-visible copy TRUE)
|
||||
(gimp-drawable-set-visible layer FALSE)
|
||||
(set! num-visi-layers (+ num-visi-layers 1))))
|
||||
(set! layer-count (+ layer-count 1)))
|
||||
|
||||
; merge all visible layers
|
||||
(if (> num-visi-layers 1)
|
||||
(set! merged-layer (car (gimp-image-merge-visible-layers image
|
||||
EXPAND-AS-NECESSARY)))
|
||||
(if (> num-visi-layers 0)
|
||||
(set! merged-layer copy)))
|
||||
(gimp-image-undo-disable image)
|
||||
|
||||
(if (> num-visi-layers 0)
|
||||
(begin
|
||||
(gimp-edit-copy merged-layer)
|
||||
(gimp-image-remove-layer image merged-layer)))
|
||||
; count the number of visible layers
|
||||
(while (> num-layers 0)
|
||||
(let* ((layer (aref layer-array (- num-layers 1)))
|
||||
(is-visible (car (gimp-drawable-get-visible layer))))
|
||||
(if (eq? is-visible TRUE)
|
||||
(begin
|
||||
(set! num-visible-layers (+ num-visible-layers 1))
|
||||
(set! visible-layer layer)))
|
||||
(set! num-layers (- num-layers 1))))
|
||||
|
||||
; restore the layers visibilty
|
||||
(set! layer-count 0)
|
||||
(while (< layer-count num-layers)
|
||||
(set! layer (aref layer-array layer-count))
|
||||
(gimp-drawable-set-visible layer (aref visi-array layer-count))
|
||||
(set! layer-count (+ layer-count 1)))
|
||||
|
||||
(if (= (car (gimp-drawable-is-layer curlayer)) 1)
|
||||
(gimp-image-set-active-layer image curlayer)
|
||||
(gimp-image-set-active-channel image curlayer))
|
||||
; if there are several visible layers, merge them
|
||||
(if (> num-visible-layers 1)
|
||||
(set! visible-layer (car (gimp-image-merge-visible-layers
|
||||
image
|
||||
EXPAND-AS-NECESSARY))))
|
||||
|
||||
(gimp-image-undo-group-end image)
|
||||
(gimp-displays-flush)))
|
||||
; copy the visible layer
|
||||
(if (> num-visible-layers 0)
|
||||
(gimp-edit-copy visible-layer))
|
||||
|
||||
; delete the temporary copy of the image
|
||||
(gimp-image-delete image)))
|
||||
|
||||
(script-fu-register "script-fu-copy-visible"
|
||||
_"<Image>/Edit/Copy _Visible"
|
||||
"Copy the visible selection"
|
||||
"Sven Neumann <sven@gimp.org>, Adrian Likins <adrian@gimp.org>"
|
||||
"Sven Neumann, Adrian Likins"
|
||||
"Sven Neumann <sven@gimp.org>, Adrian Likins <adrian@gimp.org>, Raphael Quinet <raphael@gimp.org>"
|
||||
"Sven Neumann, Adrian Likins, Raphael Quinet"
|
||||
"01/24/1998"
|
||||
"RGB* INDEXED* GRAY*"
|
||||
SF-IMAGE "Image" 0
|
||||
|
|
Loading…
Reference in a new issue