; The GIMP -- an image manipulation program
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
;
; Glogo Simple --- save as simple as possible an image as Linux Boot Logo
; Based on Jens Ch. Restmeiers' glogo plug-in
; Copyright (C) 1998 Clifford Wolf
; god@clifford.at
;
; 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-glogo-simple srcimg dummy filename)
	(let*
		(
			(img2   (car (gimp-channel-ops-duplicate srcimg)))
			(img16  (car (gimp-channel-ops-duplicate srcimg)))
			(img224 (car (gimp-channel-ops-duplicate srcimg)))
			(drawa  (car (gimp-image-active-drawable srcimg)))
			(drcol  (car (gimp-drawable-color drawa)))
		)
		;
		; Set names to the images (debug-info)
		;
		(gimp-image-set-filename img2   "glogo-bw")
		(gimp-image-set-filename img16  "glogo-16")
		(gimp-image-set-filename img224 "glogo-224")
		;
		; Resize (i.e. scale) them all
		;
		(gimp-image-scale img2   80 80)
		(gimp-image-scale img16  80 80)
		(gimp-image-scale img224 80 80)
		;
		; Convert them to RGB if they are not
		;
		(if (= drcol 0)
			(begin
				(gimp-convert-rgb img2)
				(gimp-convert-rgb img16)
				(gimp-convert-rgb img224)
			)
		)
		;
		; Flatten it
		;
		(gimp-image-flatten img2)
		(gimp-image-flatten img16)
		(gimp-image-flatten img224)
		;
		; Now change the palletes
		;
		(gimp-convert-indexed-palette img2   1 3 0   "")
		(gimp-convert-indexed-palette img16  1 0 16  "")
		(gimp-convert-indexed-palette img224 1 0 224 "")
		;
		; Save it as gifs (not needed anymore)
		;
;		(file-gif-save 1 img2   (car (gimp-image-active-drawable img2))
;		                        "/tmp/x-2.gif"   "/tmp/x-2.gif"   0 0 0 0)
;		(file-gif-save 1 img16  (car (gimp-image-active-drawable img16))
;		                        "/tmp/x-16.gif"  "/tmp/x-16.gif"  0 0 0 0)
;		(file-gif-save 1 img224 (car (gimp-image-active-drawable img224))
;		                        "/tmp/x-224.gif" "/tmp/x-224.gif" 0 0 0 0)
		;
		; Save it as linux boot logo
		;
;		(gimp-message (string-append "Debug-Info: img2=" (number->string img2 10)
;		                             " img16=" (number->string img16 10)
;		                             " img224=" (number->string img224 10)))
		(extension-linux-logo 1 filename
		                      (car (gimp-image-active-drawable img2))
		                      (car (gimp-image-active-drawable img16))
		                      (car (gimp-image-active-drawable img224)) )
		;
		; Free the images
		;
		(gimp-image-delete img2)
		(gimp-image-delete img16)
		(gimp-image-delete img224)
	)
)

(script-fu-register "script-fu-glogo-simple"
	"<Image>/Script-Fu/Save as Linux Boot Logo"
	"Saves any given image as Linux Boot Logo"
	"Clifford Wolf"
	"Clifford Wolf"
	"Aug 1998"
	""
	SF-IMAGE "Image to Glogo Simple" 0
	SF-DRAWABLE "Drawable to Glogo Simple" 0
	SF-VALUE "File Name" "\"linux_logo.h\""
)
