Skip to content

Commit

Permalink
Import version 0.5.1 from www.weitz.de.
Browse files Browse the repository at this point in the history
git-svn-id: svn://bknr.net/svn/trunk/thirdparty/cl-gd@1778 4281704c-cde7-0310-8518-8e2dc76b1ff0
  • Loading branch information
hanshuebner committed Dec 4, 2005
1 parent afa1df9 commit 6fd6658
Show file tree
Hide file tree
Showing 17 changed files with 178 additions and 85 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
Version 0.5.1
2005-10-04
Support for OpenMCL via CFFI (thanks to Bryan O'Connor)

Version 0.5.0
2005-09-26
Experimental CLISP/CFFI support (thanks to Luis Oliveira)
Don't redefine what's already there (for LispWorks)

Version 0.4.8
2005-05-17
Re-enabled the ability to build without GIF support

Version 0.4.7
2005-05-07
Added GET-PIXEL (provided by Alan Shields)

Version 0.4.6
2005-03-31
Fixed typo in WITH-IMAGE* (thanks to Peter Barabas)
Handle CMUCL search lists correctly (thanks to Hans H�bner)
Added -lc option to linker call and included makefile (thanks to Hans H�bner)

Version 0.4.5
2005-03-16
Fixed type check in MAKE-STREAM-FN (thanks to Walter C. Pelissero)
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# this should work for FreeBSD and most Linux distros

cl-gd-glue.so:
gcc -I/usr/local/include -fPIC -c cl-gd-glue.c
ld -shared -lgd -lz -lpng -ljpeg -lfreetype -liconv -lm -lc cl-gd-glue.o -o cl-gd-glue.so -L/usr/local/lib
rm cl-gd-glue.o

# this should work for Mac OS X

cl-gd-glue.dylib:
gcc -lgd -ljpeg -dynamiclib cl-gd-glue.c -o cl-gd-glue.dylib
6 changes: 5 additions & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Complete documentation for CL-GD can be found in the 'doc'
directory. Make sure to read it if you want GIF support!
directory.

CL-GD also supports Nikodemus Siivola's HYPERDOC, see
<http://common-lisp.net/project/hyperdoc/> and
Expand Down Expand Up @@ -34,6 +34,10 @@ CL-GD also supports Nikodemus Siivola's HYPERDOC, see
ld -lgd -lz -lpng -ljpeg -lfreetype -lm -liconv -shared cl-gd-glue.o -o cl-gd-glue.so
rm cl-gd-glue.o

For Mac OS X, use

gcc -lgd -ljpeg -dynamiclib cl-gd-glue.c -o cl-gd-glue.dylib

1.6. Make sure that cl-gd.asd can be seen from asdf (this is usually
achieved by a symbolic link), start your favorite Lisp, and compile
CL-GD:
Expand Down
2 changes: 2 additions & 0 deletions cl-gd-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ gdImagePtr gdImageCreateFromJpegFile (char *filename, int *err) {
return NULL;
}

#ifndef GD_DONT_USE_GIF
gdImagePtr gdImageCreateFromGifFile (char *filename, int *err) {
FILE *in;
gdImagePtr im;
Expand All @@ -61,6 +62,7 @@ gdImagePtr gdImageCreateFromGifFile (char *filename, int *err) {
*err = errno;
return NULL;
}
#endif

gdImagePtr gdImageCreateFromPngFile (char *filename, int *err) {
FILE *in;
Expand Down
7 changes: 4 additions & 3 deletions cl-gd-test.asd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*-
;;; $Header: /usr/local/cvsrep/gd/cl-gd-test.asd,v 1.7 2005/03/09 14:17:56 edi Exp $
;;; $Header: /usr/local/cvsrep/gd/cl-gd-test.asd,v 1.8 2005/09/26 12:00:59 edi Exp $

;;; Copyright (c) 2003-2005, Dr. Edmund Weitz. All rights reserved.

Expand Down Expand Up @@ -40,6 +40,7 @@
:defaults (parse-namestring *load-truename*)))

(defsystem #:cl-gd-test
:components ((:file "cl-gd-test"))
:depends-on (:cl-gd))
:version "0.4.8"
:components ((:file "cl-gd-test"))
:depends-on (:cl-gd))

6 changes: 3 additions & 3 deletions cl-gd-test.lisp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-GD; Base: 10 -*-
;;; $Header: /usr/local/cvsrep/gd/cl-gd-test.lisp,v 1.23 2005/03/09 14:17:56 edi Exp $
;;; $Header: /usr/local/cvsrep/gd/cl-gd-test.lisp,v 1.24 2005/09/26 12:50:11 edi Exp $

;;; Copyright (c) 2003-2005, Dr. Edmund Weitz. All rights reserved.

Expand Down Expand Up @@ -39,8 +39,8 @@
(defparameter *test-directory*
(merge-pathnames (make-pathname :directory '(:relative "test"))
(make-pathname :name nil
:type :unspecific
:version :unspecific
:type nil
:version :newest
:defaults cl-gd.system:*cl-gd-directory*))

"Where test files are put.")
Expand Down
30 changes: 16 additions & 14 deletions cl-gd.asd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*-
;;; $Header: /usr/local/cvsrep/gd/cl-gd.asd,v 1.7 2005/03/09 14:17:56 edi Exp $
;;; $Header: /usr/local/cvsrep/gd/cl-gd.asd,v 1.9 2005/10/04 08:45:44 edi Exp $

;;; Copyright (c) 2003-2005, Dr. Edmund Weitz. All rights reserved.

Expand Down Expand Up @@ -41,16 +41,18 @@
:defaults (parse-namestring *load-truename*)))

(defsystem #:cl-gd
:components ((:file "packages")
(:file "util" :depends-on ("packages"))
(:file "specials" :depends-on ("util"))
(:file "init" :depends-on ("specials"))
(:file "gd-uffi" :depends-on ("init"))
(:file "transform" :depends-on ("gd-uffi"))
(:file "images" :depends-on ("transform"))
(:file "colors-aux" :depends-on ("transform"))
(:file "colors" :depends-on ("transform"))
(:file "drawing" :depends-on ("transform" "colors-aux"))
(:file "strings" :depends-on ("transform" "colors-aux"))
(:file "misc" :depends-on ("transform")))
:depends-on (:uffi))
:version "0.5.1"
:components ((:file "packages")
(:file "util" :depends-on ("packages"))
(:file "specials" :depends-on ("util"))
(:file "init" :depends-on ("specials"))
(:file "gd-uffi" :depends-on ("init"))
(:file "transform" :depends-on ("gd-uffi"))
(:file "images" :depends-on ("transform"))
(:file "colors-aux" :depends-on ("transform"))
(:file "colors" :depends-on ("transform"))
(:file "drawing" :depends-on ("transform" "colors-aux"))
(:file "strings" :depends-on ("transform" "colors-aux"))
(:file "misc" :depends-on ("transform")))
:depends-on (#-(or :clisp :openmcl) :uffi
#+(or :clisp :openmcl) :cffi-uffi-compat))
14 changes: 7 additions & 7 deletions colors.lisp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-GD; Base: 10 -*-
;;; $Header: /usr/local/cvsrep/gd/colors.lisp,v 1.22 2005/03/09 14:17:56 edi Exp $
;;; $Header: /usr/local/cvsrep/gd/colors.lisp,v 1.23 2005/09/26 12:50:11 edi Exp $

;;; Copyright (c) 2003-2005, Dr. Edmund Weitz. All rights reserved.

Expand Down Expand Up @@ -167,13 +167,13 @@ restored before the macro exits. Note that the line width is measured
in pixels and is not affected by WITH-TRANSFORMATION."
(with-unique-names (old-thickness)
;; we rebind everything so we have left-to-right evaluation
(rebinding (thickness image)
(with-rebinding (thickness image)
`(let ((,old-thickness (thickness ,image)))
(unwind-protect
(progn
(setf (thickness ,image) ,thickness))
,@body)
(setf (thickness ,image) ,old-thickness)))))
(unwind-protect
(progn
(setf (thickness ,image) ,thickness))
,@body)
(setf (thickness ,image) ,old-thickness)))))

(defun alpha-blending-p (&optional (image *default-image*))
"Returns whether pixels drawn on IMAGE will be copied literally
Expand Down
41 changes: 34 additions & 7 deletions doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,24 @@ <h2>CL-GD - Use the GD Graphics Library from Common Lisp</h2>
<a href="http://www.boutell.com/gd/">GD Graphics Library</a> for the
dynamic creation of images. It is based on <a
href="http://uffi.b9.com/">UFFI</a> and should thus be portable to all
CL implementations supported by UFFI. (A version which also works with CLISP is available from <a href="http://ungil.com/cl-gd-clisp.tgz">http://ungil.com/cl-gd-clisp.tgz</a> thanks to Carlos Ungil.)
CL implementations supported by UFFI.
<p>
A version which also works with CLISP is available from <a
href="http://ungil.com/cl-gd-clisp.tgz">http://ungil.com/cl-gd-clisp.tgz</a>
thanks to Carlos Ungil. Also, beginning from version 0.5.0/0.5.1, CL-GD
contains initial code to support CLISP and OpenMCL via <a
href="http://common-lisp.net/project/cffi/">CFFI</a> (<a href="http://common-lisp.net/pipermail/cl-gd-devel/2005-September/000030.html">thanks to Luis
Oliveira</a> and Bryan O'Connor). Please try it and report to <a href="#mail">the mailing list</a> if you
have problems.
<p>
The focus of CL-GD is convenience and correctness, not necessarily speed. If you think CL-GD is too slow and you're concerned about speed, <a href="#mail">contact me</a> before you start coding in C... :)
<p>
CL-GD comes with a <a
href="http://www.opensource.org/licenses/bsd-license.php">BSD-style
license</a> so you can basically do with it whatever you want. Please send bug reports to <a href="#mail">the mailing list</a> mentioned below if you encounter any problems with CL-GD. (I'm glad to fix CL-GD but I can't do much about GD, of course. So if CL-GD basically works for you but you encounter seemingly strange behaviour when drawing please try if and how you can achieve the intended result with GD directly. That would help me a lot. Thanks.)
<p>
CL-GD is used by <a href="http://www.eboy.com/">Eboy</a>.

<p>
<font color=red>Download shortcut:</font> <a href="http://weitz.de/files/cl-gd.tar.gz">http://weitz.de/files/cl-gd.tar.gz</a>.
</blockquote>
Expand Down Expand Up @@ -140,6 +151,7 @@ <h2>CL-GD - Use the GD Graphics Library from Common Lisp</h2>
</ul>
<li><a href="#drawing">Drawing and filling</a>
<ul>
<li><a href="#get-pixel"><code>get-pixel</code></a>
<li><a href="#set-pixel"><code>set-pixel</code></a>
<li><a href="#set-pixels"><code>set-pixels</code></a>
<li><a href="#draw-line"><code>draw-line</code></a>
Expand Down Expand Up @@ -185,19 +197,24 @@ <h2>CL-GD - Use the GD Graphics Library from Common Lisp</h2>

CL-GD together with this documentation can be downloaded from <a
href="http://weitz.de/files/cl-gd.tar.gz">http://weitz.de/files/cl-gd.tar.gz</a>. The
current version is 0.4.5. A <a href="http://packages.debian.org/cgi-bin/search_packages.pl?keywords=cl-gd&searchon=names&subword=1&version=all&release=all">Debian package</a> is available thanks to <a href="http://pvaneynd.mailworks.org/">Peter van Eynde</a> and <a href="http://b9.com/">Kevin Rosenberg</a>, so if you're on Debian you should have no problems installing CL-GD. There's also a port
current version is 0.5.1. A <a href="http://packages.debian.org/cgi-bin/search_packages.pl?keywords=cl-gd&searchon=names&subword=1&version=all&release=all">Debian package</a> is available thanks to <a href="http://pvaneynd.mailworks.org/">Peter van Eynde</a> and <a href="http://b9.com/">Kevin Rosenberg</a>, so if you're on Debian you should have no problems installing CL-GD. There's also a port
for <a href="http://www.cliki.net/gentoo">Gentoo Linux</a> thanks to Matthew Kennedy. Otherwise, proceed like this:
<ul>
<li>Download and install a recent version of <a href="http://www.cliki.net/asdf">asdf</a>.
<li>Download and install <a href="http://uffi.b9.com/">UFFI</a>. CL-GD needs at least version&nbsp;1.3.4 of UFFI to work properly. However, as of August 2003, only AllegroCL, CMUCL, LispWorks, SBCL, and SCL are fully supported because CL-GD needs the new UFFI macros <a href="http://uffi.b9.com/manual/with-cast-pointer.html"><code>WITH-CAST-POINTER</code></a> and <a href="http://uffi.b9.com/manual/def-foreign-var.html"><code>DEF-FOREIGN-VAR</code></a> which haven't yet been ported to all UFFI platforms.
<li>Download and install <a href="http://uffi.b9.com/">UFFI</a>. CL-GD needs at least version&nbsp;1.3.4 of UFFI to work properly. However, as of August 2003, only AllegroCL, CMUCL, LispWorks, SBCL, and SCL are fully supported because CL-GD needs the new UFFI macros <a href="http://uffi.b9.com/manual/with-cast-pointer.html"><code>WITH-CAST-POINTER</code></a> and <a href="http://uffi.b9.com/manual/def-foreign-var.html"><code>DEF-FOREIGN-VAR</code></a> which haven't yet been ported to all UFFI platforms. <b>Note:</b> For CLISP or OpenMCL download and install <a
href="http://common-lisp.net/project/cffi/">CFFI</a> instead.
<li>Download and install a recent version of <a href="http://www.boutell.com/gd/">GD</a> and its supporting libraries <a href="http://www.libpng.org/pub/png/">libpng</a>, <a href="http://www.info-zip.org/pub/infozip/zlib/">zlib</a>, <a href="http://www.ijg.org/">libjpeg</a>, <a href="http://www.gnu.org/software/libiconv/">libiconv</a>, and <a href="http://www.freetype.org/">libfreetype</a>. CL-GD has been tested and developed with GD 2.0.28, older version probably won't work. Note that you won't be able to compile CL-GD unless you have installed <em>all</em> supporting libraries. This is different from using GD directly from C where you only have to install the libraries you intend to use.
<li>Download <a href="http://weitz.de/files/cl-gd.tar.gz"><code>cl-gd.tar.gz</code></a>, unzip and untar the file and put the resulting directory wherever you want, then cd into this directory.
<li>Compile <code>cl-gd-glue.c</code> into a shared library for your platform. On Linux this would be
<li>Compile <code>cl-gd-glue.c</code> into a shared library for your platform. On FreeBSD or Linux this would be
<pre>
gcc -fPIC -c cl-gd-glue.c
ld -lgd -lz -lpng -ljpeg -lfreetype -lm -liconv -shared cl-gd-glue.o -o cl-gd-glue.so
rm cl-gd-glue.o
</pre>
For Mac OS X, use
<pre>
gcc -lgd -ljpeg -dynamiclib cl-gd-glue.c -o cl-gd-glue.dylib
</pre>
<li>Make sure that <code>cl-gd.asd</code> can be seen from asdf (this is usually achieved by a symbolic link), start your favorite Lisp, and compile CL-GD:
<pre>
(asdf:oos 'asdf:compile-op :cl-gd)
Expand All @@ -206,6 +223,8 @@ <h2>CL-GD - Use the GD Graphics Library from Common Lisp</h2>
<pre>
(asdf:oos 'asdf:load-op :cl-gd)
</pre>
<li>To build <em>without</em> GIF support compile the C library with the option <code>-DGD_DONT_USE_GIF</code> and push the symbol <code>:CL-GD-NO-GIF</code> onto <a href="http://www.lispworks.com/documentation/HyperSpec/Body/v_featur.htm"><code>*FEATURES*</code></a> <em>before</em> compiling CL-GD.

<li>CL-GD comes with a simple test suite that can be used to check if it's
basically working. Note that this'll only test a subset of CL-GD. To
run the tests load CL-GD and then
Expand Down Expand Up @@ -471,12 +490,12 @@ <h2>CL-GD - Use the GD Graphics Library from Common Lisp</h2>
</blockquote>

<p><br>[Function]
<br><a class=none name="write-image-to-file"><b>write-image-to-file</b> <i>file-name type if-exists <tt>&amp;key</tt> <tt>&amp;allow-other-keys</tt></i> =&gt; <i>image</i></a>
<br><a class=none name="write-image-to-file"><b>write-image-to-file</b> <i>file-name <tt>&amp;key</tt> type if-exists <tt>&amp;allow-other-keys</tt></i> =&gt; <i>image</i></a>

<blockquote><br>
Writes image <code><i>image</i></code> to the file specified by <code><i>file-name</i></code> (which is
either a pathname or a string). The <code><i>type</i></code> argument is interpreted as in <a href="#write-image-to-stream"><code>WRITE-IMAGE-TO-STREAM</code></a>. If it is not provided it will be guessed from the <code>PATHNAME-TYPE</code> of
<code><i>file-name</i></code>. The <code><i>if-exists</i></code> keyword argument is given to <a href="http://www.lispworks.com/reference/HyperSpec/Body/f_open.htm"><code>OPEN</code></a>,
<code><i>file-name</i></code>. The <code><i>if-exists</i></code> keyword argument is given to <a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_open.htm"><code>OPEN</code></a>,
the rest of the keyword arguments are handed over to the corresponding <code>WRITE-<i>XXX</i>-TO-STREAM</code> function.
</blockquote>

Expand Down Expand Up @@ -866,6 +885,13 @@ <h2>CL-GD - Use the GD Graphics Library from Common Lisp</h2>

This section (and the next one about <a href="#strings">strings</a>) finally describes how you can actually change the visual appearance of an <a href="#images">image</a>. You can set single pixels, draw lines or geometric figures, and fill regions. Note that the current <a href="#transformations">transformation</a> (if any) applies to the input and output of these functions.

<p><br>[Function]
<br><a class=none name="get-pixel"><b>get-pixel</b> <i>x y <tt>&amp;key</tt> image</i> =&gt; <i>color</i></a>

<blockquote><br>
Returns the <a href="#colors">color</a> of the pixel specified by <code><i>x</i></code> and <code><i>y</i></code>.
</blockquote>

<p><br>[Function]
<br><a class=none name="set-pixel"><b>set-pixel</b> <i>x y <tt>&amp;key</tt> color image</i> =&gt; <i>x, y</i></a>

Expand Down Expand Up @@ -1390,8 +1416,9 @@ <h2>CL-GD - Use the GD Graphics Library from Common Lisp</h2>
not have been possible. Kevin was also extremely helpful when I needed
functionality which wasn't yet part of UFFI. Thanks to <a href="http://huebner.org/">Hans
H&uuml;bner</a> for the GIF patches. Thanks to <a href='http://bl0rg.net/'>Manuel Odendahl</a> for lots of useful patches.
Thanks to Luis Oliveira for CLISP/CFFI support.
<p>
$Header: /usr/local/cvsrep/gd/doc/index.html,v 1.48 2005/03/16 15:31:40 edi Exp $
$Header: /usr/local/cvsrep/gd/doc/index.html,v 1.56 2005/10/04 08:45:45 edi Exp $
<p><a href="http://weitz.de/index.html">BACK TO MY HOMEPAGE</a>

</body>
Expand Down
46 changes: 27 additions & 19 deletions drawing.lisp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-GD; Base: 10 -*-
;;; $Header: /usr/local/cvsrep/gd/drawing.lisp,v 1.24 2005/03/09 14:17:56 edi Exp $
;;; $Header: /usr/local/cvsrep/gd/drawing.lisp,v 1.26 2005/09/26 12:50:11 edi Exp $

;;; Copyright (c) 2003-2005, Dr. Edmund Weitz. All rights reserved.

Expand Down Expand Up @@ -29,6 +29,14 @@

(in-package :cl-gd)

(defun get-pixel (x y &key (image *default-image*))
"Gets the color associated with point \(X,Y)."
(check-type image image)
(with-transformed-alternative
((x x-transformer)
(y y-transformer))
(gd-image-get-pixel (img image) x y)))

(defun set-pixel (x y &key (color *default-color*) (image *default-image*))
"Draws a pixel with color COLOR at point \(X,Y)."
(check-type image image)
Expand Down Expand Up @@ -315,32 +323,32 @@ left corner \(X1, Y1) and lower right corner \(X2, Y2)."
which should be a list \(X1 Y1 X2 Y2). The previous clipping rectangle
is guaranteed to be restored before the macro exits."
;; we rebind everything so we have left-to-right evaluation
(rebinding (rectangle image)
(with-rebinding (rectangle image)
(with-unique-names (%x1 %y1 %x2 %y2)
`(multiple-value-bind (,%x1 ,%y1 ,%x2 ,%y2)
(without-transformations
(clipping-rectangle* ,image))
(unwind-protect
(progn
(setf (clipping-rectangle ,image) ,rectangle)
,@body)
(without-transformations
(set-clipping-rectangle* ,%x1 ,%y1 ,%x2 ,%y2 ,image)))))))
(without-transformations
(clipping-rectangle* ,image))
(unwind-protect
(progn
(setf (clipping-rectangle ,image) ,rectangle)
,@body)
(without-transformations
(set-clipping-rectangle* ,%x1 ,%y1 ,%x2 ,%y2 ,image)))))))

(defmacro with-clipping-rectangle* ((x1 y1 x2 y2 &key (image '*default-image*)) &body body)
"Executes BODY with the clipping rectangle of IMAGE set to the
rectangle with upper left corner \(X1, Y1) and lower right corner
\(X2, Y2). The previous clipping rectangle is guaranteed to be
restored before the macro exits."
;; we rebind everything so we have left-to-right evaluation
(rebinding (x1 y1 x2 y2 image)
(with-rebinding (x1 y1 x2 y2 image)
(with-unique-names (%x1 %y1 %x2 %y2)
`(multiple-value-bind (,%x1 ,%y1 ,%x2 ,%y2)
(without-transformations
(clipping-rectangle* ,image))
(unwind-protect
(progn
(set-clipping-rectangle* ,x1 ,y1 ,x2 ,y2 ,image)
,@body)
(without-transformations
(set-clipping-rectangle* ,%x1 ,%y1 ,%x2 ,%y2 ,image)))))))
(without-transformations
(clipping-rectangle* ,image))
(unwind-protect
(progn
(set-clipping-rectangle* ,x1 ,y1 ,x2 ,y2 ,image)
,@body)
(without-transformations
(set-clipping-rectangle* ,%x1 ,%y1 ,%x2 ,%y2 ,image)))))))
Loading

0 comments on commit 6fd6658

Please sign in to comment.