~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to plug-ins/script-fu/scripts/select-to-image.scm

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
; The GIMP -- an image manipulation program
 
1
; GIMP - The GNU Image Manipulation Program
2
2
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
 
 
3
;
4
4
; Selection to Image
5
5
; Copyright (c) 1997 Adrian Likins
6
6
; aklikins@eos.ncsu.edu
12
12
; it under the terms of the GNU General Public License as published by
13
13
; the Free Software Foundation; either version 2 of the License, or
14
14
; (at your option) any later version.
15
 
 
15
;
16
16
; This program is distributed in the hope that it will be useful,
17
17
; but WITHOUT ANY WARRANTY; without even the implied warranty of
18
18
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
19
; GNU General Public License for more details.
20
 
 
20
;
21
21
; You should have received a copy of the GNU General Public License
22
22
; along with this program; if not, write to the Free Software
23
23
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
24
 
25
25
 
26
26
(define (script-fu-selection-to-image image drawable)
27
 
  (let* ((draw-type (car (gimp-drawable-type-with-alpha drawable)))
28
 
         (image-type (car (gimp-image-base-type image)))
29
 
         (selection-bounds (gimp-selection-bounds image))
30
 
         (select-offset-x  (cadr selection-bounds))
31
 
         (select-offset-y  (caddr selection-bounds))
32
 
         (selection-width  (- (cadr (cddr selection-bounds)) select-offset-x))
33
 
         (selection-height (- (caddr (cddr selection-bounds)) select-offset-y)))
 
27
  (let* (
 
28
        (draw-type (car (gimp-drawable-type-with-alpha drawable)))
 
29
        (image-type (car (gimp-image-base-type image)))
 
30
        (selection-bounds (gimp-selection-bounds image))
 
31
        (select-offset-x (cadr selection-bounds))
 
32
        (select-offset-y (caddr selection-bounds))
 
33
        (selection-width (- (cadr (cddr selection-bounds)) select-offset-x))
 
34
        (selection-height (- (caddr (cddr selection-bounds)) select-offset-y))
 
35
        (active-selection)
 
36
        (from-selection)
 
37
        (new-image)
 
38
        (new-draw)
 
39
        )
34
40
 
35
41
    (gimp-context-push)
36
42
 
37
43
    (gimp-image-undo-disable image)
38
 
    
 
44
 
39
45
    (if (= (car (gimp-selection-is-empty image)) TRUE)
40
 
        (begin
41
 
          (gimp-selection-layer-alpha drawable)
42
 
          (set! active-selection (car (gimp-selection-save image)))
43
 
          (set! from-selection FALSE))
44
 
        (begin
45
 
          (set! from-selection TRUE)
46
 
          (set! active-selection (car (gimp-selection-save image)))))
 
46
        (begin
 
47
          (gimp-selection-layer-alpha drawable)
 
48
          (set! active-selection (car (gimp-selection-save image)))
 
49
          (set! from-selection FALSE)
 
50
        )
 
51
        (begin
 
52
          (set! from-selection TRUE)
 
53
          (set! active-selection (car (gimp-selection-save image)))
 
54
        )
 
55
    )
47
56
 
48
57
    (gimp-edit-copy drawable)
49
58
 
50
59
    (set! new-image (car (gimp-image-new selection-width
51
 
                                         selection-height image-type)))
 
60
                                         selection-height image-type)))
52
61
    (set! new-draw (car (gimp-layer-new new-image
53
 
                                        selection-width selection-height
54
 
                                        draw-type "Selection" 100 NORMAL-MODE)))
 
62
                                        selection-width selection-height
 
63
                                        draw-type "Selection" 100 NORMAL-MODE)))
55
64
    (gimp-image-add-layer new-image new-draw 0)
56
65
    (gimp-drawable-fill new-draw BACKGROUND-FILL)
57
66
 
58
67
    (let ((floating-sel (car (gimp-edit-paste new-draw FALSE))))
59
 
      (gimp-floating-sel-anchor floating-sel))
 
68
      (gimp-floating-sel-anchor floating-sel)
 
69
    )
60
70
 
61
71
    (gimp-image-undo-enable image)
62
72
    (gimp-image-set-active-layer image drawable)
63
73
    (gimp-display-new new-image)
64
74
    (gimp-displays-flush)
65
75
 
66
 
    (gimp-context-pop)))
 
76
    (gimp-context-pop)
 
77
  )
 
78
)
67
79
 
68
80
(script-fu-register "script-fu-selection-to-image"
69
 
                    _"To _Image"
70
 
                    "Convert a selection to an image"
71
 
                    "Adrian Likins <adrian@gimp.org>"
72
 
                    "Adrian Likins"
73
 
                    "10/07/97"
74
 
                    "RGB* GRAY*"
75
 
                    SF-IMAGE    "Image"    0
76
 
                    SF-DRAWABLE "Drawable" 0)
77
 
 
78
 
(script-fu-menu-register "script-fu-selection-to-image"
79
 
                         _"<Image>/Script-Fu/Selection")
 
81
  _"To _Image"
 
82
  _"Convert a selection to an image"
 
83
  "Adrian Likins <adrian@gimp.org>"
 
84
  "Adrian Likins"
 
85
  "10/07/97"
 
86
  "RGB* GRAY*"
 
87
  SF-IMAGE "Image"       0
 
88
  SF-DRAWABLE "Drawable" 0
 
89
)