Re: [Gimp-developer] Script-Fu Bug Gimp-2.0pre2

2004-01-23 Thread Jeff Trefftzs
On Thu, 2004-01-22 at 16:29, Simon Budig wrote:

> Try the gimp-layer-set-edit-mask function. This seems the function
> of choice in your case (I did not test it though).
> 
> Bye,
> Simon

Thanks, Simon.  That did it.
-- 

--Jeff

Jeff Trefftzs <[EMAIL PROTECTED]>
http://www.tcsn.net/trefftzsHome Page
http://gug.sunsite.dk/gallery.php?artist=68 Gimp Gallery
http://trefftzs.topcities.com/  Photo Gallery 

___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Script-Fu Bug Gimp-2.0pre2

2004-01-22 Thread Jeff Trefftzs
On Thu, 2004-01-22 at 16:29, Simon Budig wrote:
> Jeff Trefftzs ([EMAIL PROTECTED]) wrote:
> > I've been trying to port one of my scheme scripts to 2.0pre2 and have
> > discovered what I think is a bug.  Before I battle with bugzilla, would
> > someone try to reproduce it?
> 
> Not until you provide the script  :)
> 
Herewith:

;;;
;;; pencil-sketch.scm
;;;
;;;
;;;  Jeff Trefftzs <[EMAIL PROTECTED]>

;;; 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
;;; (at your option) any later version.
;;; 
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;; 
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

;;; Changelog:
;;; 020113 - Version 1.1.  Added multiple choice for edge detection
;;; 020113 - Version 1.01. Fixed mask texture bug.
;;; 020113 - Version 1.0.  Initial Release.

;;; Define the function:

(define (script-fu-pencil-sketch inImage inLayer
 inWeight
 inDark
 inMono
 inEdges
 inMaskPat
 inTextToggle
 inTexture)
  (let*
  (
   (WhiteLayer (car (gimp-layer-copy inLayer TRUE)))
   (MaskedLayer (car (gimp-layer-copy inLayer TRUE)))
   (EdgeLayer (car (gimp-layer-copy inLayer TRUE)))
   (LayerMask (car (gimp-layer-create-mask MaskedLayer 0)))
   )

(gimp-image-undo-group-start inImage) ; changed for 1.3/2.0

(gimp-image-add-layer inImage WhiteLayer -1)
(gimp-image-add-layer inImage MaskedLayer -1)
(gimp-image-add-layer inImage EdgeLayer -1)


(gimp-drawable-set-name WhiteLayer "Paper Layer") ; changed for
1.3/2.0
(gimp-drawable-set-name MaskedLayer "Copy with layer mask")
(gimp-drawable-set-name EdgeLayer "Edges from original image")

;; Real work goes in here

(gimp-drawable-fill WhiteLayer WHITE-IMAGE-FILL) ; Fill the white
layer
(if (> inTextToggle 0)
(begin 
  (gimp-patterns-set-pattern inTexture)
  (gimp-edit-bucket-fill WhiteLayer PATTERN-BUCKET-FILL NORMAL-MODE
100 0 FALSE 0 0) ; changed for 1.3/2.0
  )
)

;;  Create the layer mask and put the paper pattern in it.

(gimp-layer-add-mask MaskedLayer LayerMask) ; changed for 1.3/2.0
(gimp-image-set-active-channel inImage LayerMask)
(gimp-patterns-set-pattern inMaskPat)
(gimp-bucket-fill LayerMask PATTERN-BUCKET-FILL NORMAL-MODE
  100   ; opacity
  0 ; threshold
  FALSE ; no sample-merged
  0 0)  ; X, Y coords
(gimp-image-unset-active-channel inImage) ; finished with it

;;  Now find the edges

(gimp-image-set-active-layer inImage EdgeLayer)

;; Edge Detection Here

(cond ((= inEdges 0); Laplacian edges
   (plug-in-gauss-iir TRUE inImage EdgeLayer inWeight TRUE TRUE)
   (plug-in-laplace TRUE inImage EdgeLayer))

  ((= inEdges 1); Sobel Edges
   (plug-in-sobel TRUE inImage EdgeLayer TRUE TRUE TRUE))

  ;; Synthetic Edges here - Include desaturate if needed

  ((= inEdges 2); Synthetic Edges
   (set! tmplayer (car (gimp-layer-copy EdgeLayer TRUE)))
   (gimp-image-add-layer inImage tmplayer -1)
   (gimp-layer-set-mode tmplayer DIVIDE-MODE)
   (plug-in-gauss-iir TRUE inImage tmplayer inWeight TRUE TRUE)
   (set! EdgeLayer 
 (car (gimp-image-merge-down inImage tmplayer
 EXPAND-AS-NECESSARY)))
   (gimp-levels EdgeLayer VALUE-LUT
inDark  ; low input
255 ; high input
1.0 ; gamma
0 255)  ; output 

   ;; Desaturate if needed

   (if (= inMono TRUE)
   (gimp-desaturate EdgeLayer)
   )
   )
  ) ; end cond

(gimp-layer-set-mode EdgeLayer DARKEN-ONLY-MODE) ; in case white bg

(gimp-image-set-active-layer inImage inLayer)
(gimp-undo-push-group-end inImage)
(gimp-displays-flush)
)
  )

(script-fu-register
 "script-fu-pencil-sketch"
 _"/Script-Fu/Alchemy/Pencil Sketch..."
 "Creates an 

Re: [Gimp-developer] Script-Fu Bug Gimp-2.0pre2

2004-01-22 Thread Simon Budig
Jeff Trefftzs ([EMAIL PROTECTED]) wrote:
> I've been trying to port one of my scheme scripts to 2.0pre2 and have
> discovered what I think is a bug.  Before I battle with bugzilla, would
> someone try to reproduce it?

Not until you provide the script  :)

> Details:  my script adds a layer mask to a layer (this works), but when
> I attempt to make the layer mask the active channel, using
> gimp-image-set-active-channel I consistently get an error:
> 
> ERROR: Procedural database execution failed:
> (gimp_image_set_active_channel 2 9)

I think that this only refers to channels that are listed in the
channels dialog (not the RGB-Channels but the ones below).

Try the gimp-layer-set-edit-mask function. This seems the function
of choice in your case (I did not test it though).

Bye,
Simon

-- 
  [EMAIL PROTECTED]   http://www.home.unix-ag.org/simon/
___
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer