;; Copyright (C) 2002 Ingo Ruhnke ;; ;; 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 (read-anim-ccl) (let ((port (fopen "/tmp/anim.ccl")) (lst) (read port) ))) (define (seperate-image num-rows num-columns) #f) (define (quotient a b) (/ a b)) (define (freecraft:clean-up-image image drawable) ;; Remove the background, change player color #f) (define (freecraft-animpreview filename output-filename num-rows num-columns) (let* ((image (car (gimp-file-load 1 filename filename))) (drawable (aref (cadr (gimp-image-get-layers image)) 0)) (width (car (gimp-image-width image))) (height (car (gimp-image-height image))) (frame-width (quotient width num-columns)) (frame-height (quotient height num-rows)) (new-image (car (gimp-image-new frame-width frame-height RGB)))) (freecraft:clean-up-image image drawable) (let ((pos-x 0)) (while (< pos-x num-columns) (let ((pos-y 0)) (while (< pos-y num-rows) (let ((new-drawable (car (gimp-layer-new new-image frame-width frame-height RGBA-IMAGE "layer" 100 NORMAL)))) (gimp-edit-clear new-drawable) (gimp-image-add-layer new-image new-drawable -1) (gimp-rect-select image (* pos-x frame-width) (* pos-y frame-height) frame-width frame-height REPLACE 0 0) (gimp-edit-copy drawable) (gimp-floating-sel-anchor (car (gimp-edit-paste new-drawable 1)))) (set! pos-y (+ pos-y 1)))) (set! pos-x (+ pos-x 1)))) (gimp-image-delete image) (gimp-convert-indexed new-image 0 0 255 0 0 "") (file-gif-save 1 new-image 0 output-filename output-filename 0 1 250 2) (gimp-image-delete new-image) ;;(gimp-display-new new-image) ;;(gimp-displays-flush) )) ; Register the function with the GIMP: (script-fu-register "freecraft-animpreview" "/Xtns/Script-Fu/Freecraft/png2gif" "foo" "Ingo Ruhnke" "2002 Ingo Ruhnke" "Fri Aug 2 17:36:51 2002" "" SF-FILENAME "Filename" "/tmp/battleship.png" SF-FILENAME "Output" "/tmp/out.gif" SF-VALUE "Rows" "3" SF-VALUE "Columns" "5") ;; EOF ;;