
2008-01-15 Kevin Cozens <kcozens@cvs.gnome.org> * plug-ins/script-fu/scripts/3d-outline.scm * plug-ins/script-fu/scripts/add-bevel.scm * plug-ins/script-fu/scripts/burn-in-anim.scm * plug-ins/script-fu/scripts/camo.scm * plug-ins/script-fu/scripts/circuit.scm * plug-ins/script-fu/scripts/clothify.scm * plug-ins/script-fu/scripts/coffee.scm * plug-ins/script-fu/scripts/contactsheet.scm * plug-ins/script-fu/scripts/distress-selection.scm * plug-ins/script-fu/scripts/flatland.scm * plug-ins/script-fu/scripts/font-map.scm * plug-ins/script-fu/scripts/fuzzyborder.scm * plug-ins/script-fu/scripts/glossy.scm * plug-ins/script-fu/scripts/land.scm * plug-ins/script-fu/scripts/lava.scm * plug-ins/script-fu/scripts/old-photo.scm * plug-ins/script-fu/scripts/predator.scm * plug-ins/script-fu/scripts/rendermap.scm * plug-ins/script-fu/scripts/ripply-anim.scm * plug-ins/script-fu/scripts/script-fu-set-cmap.scm * plug-ins/script-fu/scripts/select-to-brush.scm * plug-ins/script-fu/scripts/select-to-image.scm * plug-ins/script-fu/scripts/select-to-pattern.scm * plug-ins/script-fu/scripts/speed-text.scm * plug-ins/script-fu/scripts/spinning-globe.scm * plug-ins/script-fu/scripts/test-sphere.scm * plug-ins/script-fu/scripts/text-circle.scm * plug-ins/script-fu/scripts/unsharp-mask.scm * plug-ins/script-fu/scripts/xach-effect.scm: Variables in a let block must be of the form (variable value) per the R5RS. svn path=/trunk/; revision=24614
66 lines
2.3 KiB
Scheme
66 lines
2.3 KiB
Scheme
; Set Colormap v1.1 September 29, 2004
|
|
; by Kevin Cozens <kcozens@interlog.com>
|
|
;
|
|
; Change the colourmap of an image to the colours in a specified palette.
|
|
; Included is script-fu-make-cmap-array (available for use in scripts) which
|
|
; returns an INT8ARRAY containing the colours from a specified palette.
|
|
; This array can be used as the cmap argument for gimp-image-set-cmap.
|
|
|
|
; GIMP - The GNU Image Manipulation Program
|
|
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
;
|
|
; 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.
|
|
|
|
(define (script-fu-make-cmap-array palette)
|
|
(let* (
|
|
(num-colours (car (gimp-palette-get-info palette)))
|
|
(cmap (cons-array (* num-colours 3) 'byte))
|
|
(colour 0)
|
|
(i 0)
|
|
)
|
|
|
|
(while (< i num-colours)
|
|
(set! colour (car (gimp-palette-entry-get-color palette i)))
|
|
(aset cmap (* i 3) (car colour))
|
|
(aset cmap (+ (* i 3) 1) (cadr colour))
|
|
(aset cmap (+ (* i 3) 2) (caddr colour))
|
|
(set! i (+ i 1))
|
|
)
|
|
|
|
cmap
|
|
)
|
|
)
|
|
|
|
(define (script-fu-set-cmap img drawable palette)
|
|
(gimp-image-set-colormap img
|
|
(* (car (gimp-palette-get-info palette)) 3)
|
|
(script-fu-make-cmap-array palette))
|
|
(gimp-displays-flush)
|
|
)
|
|
|
|
(script-fu-register "script-fu-set-cmap"
|
|
_"Se_t Colormap..."
|
|
_"Change the colormap of an image to the colors in a specified palette."
|
|
"Kevin Cozens <kcozens@interlog.com>"
|
|
"Kevin Cozens"
|
|
"September 29, 2004"
|
|
"INDEXED*"
|
|
SF-IMAGE "Image" 0
|
|
SF-DRAWABLE "Drawable" 0
|
|
SF-PALETTE _"Palette" "Default"
|
|
)
|
|
|
|
(script-fu-menu-register "script-fu-set-cmap" "<Image>/Colors/Map/Colormap")
|