On Thu, 18 Nov 2004 11:46:43 -0800 (PST), joe fred <bihuziro(a)volcanomail.com> wrote:
> GD does look like it would work for me and there is a pre-compiled
> windows library for it at
>
> http://www.boutell.com/gd/manual2.0.33.html#getgd (NOTE: the library
> file there is called "bgd.dll" instead of "gd.dll".)
>
> I'm able to compile cl-gd-glue-gif.c ok with
> gcc -Id:/local/graphics/gd/gdwin32 -c cl-gd-glue-gif.c
>
> Unfortunately, I'm not able to link cl-gd-glue-gif.o, see below.
> Apparently six years of Java have atrophied my windows' C skills
> down to the most basic level.
>
> Thanks to Harley and Edi for their help, but it looks like I'll need
> to spend some time relearning basic C linking before I get on with
> GD & cl-gd.
>
> ld -Ld:/local/graphics/gd/gdwin32 -lbgd -lz -lpng -ljpeg -lfreetype -lm -liconv -lbgd -shared cl-gd-glue-gif.o -o cl-gd-glue-gif.dll
> cl-gd-glue-gif.o(.text+0x16):cl-gd-glue-gif.c: undefined reference to `fopen'
> cl-gd-glue-gif.o(.text+0x2a):cl-gd-glue-gif.c: undefined reference to `gdImageCreateFromJpeg'
> cl-gd-glue-gif.o(.text+0x50):cl-gd-glue-gif.c: undefined reference to `fclose'
> cl-gd-glue-gif.o(.text+0x60):cl-gd-glue-gif.c: undefined reference to `__errno'
> cl-gd-glue-gif.o(.text+0x8e):cl-gd-glue-gif.c: undefined reference to `fopen'
> cl-gd-glue-gif.o(.text+0xa2):cl-gd-glue-gif.c: undefined reference to `gdImageCreateFromGif'
> cl-gd-glue-gif.o(.text+0xc8):cl-gd-glue-gif.c: undefined reference to `fclose'
> cl-gd-glue-gif.o(.text+0xd8):cl-gd-glue-gif.c: undefined reference to `__errno'
> cl-gd-glue-gif.o(.text+0x106):cl-gd-glue-gif.c: undefined reference to `fopen'
> cl-gd-glue-gif.o(.text+0x11a):cl-gd-glue-gif.c: undefined reference to `gdImageCreateFromPng'
> cl-gd-glue-gif.o(.text+0x140):cl-gd-glue-gif.c: undefined reference to `fclose'
> cl-gd-glue-gif.o(.text+0x150):cl-gd-glue-gif.c: undefined reference to `__errno'
> cl-gd-glue-gif.o(.text+0x17e):cl-gd-glue-gif.c: undefined reference to `fopen'
> cl-gd-glue-gif.o(.text+0x192):cl-gd-glue-gif.c: undefined reference to `gdImageCreateFromGd'
> cl-gd-glue-gif.o(.text+0x1b8):cl-gd-glue-gif.c: undefined reference to `fclose'
> cl-gd-glue-gif.o(.text+0x1c8):cl-gd-glue-gif.c: undefined reference to `__errno'
> cl-gd-glue-gif.o(.text+0x1f6):cl-gd-glue-gif.c: undefined reference to `fopen'
> cl-gd-glue-gif.o(.text+0x20a):cl-gd-glue-gif.c: undefined reference to `gdImageCreateFromGd2'
> cl-gd-glue-gif.o(.text+0x230):cl-gd-glue-gif.c: undefined reference to `fclose'
> cl-gd-glue-gif.o(.text+0x240):cl-gd-glue-gif.c: undefined reference to `__errno'
> cl-gd-glue-gif.o(.text+0x26e):cl-gd-glue-gif.c: undefined reference to `fopen'
> cl-gd-glue-gif.o(.text+0x29e):cl-gd-glue-gif.c: undefined reference to `gdImageCreateFromGd2Part'
> cl-gd-glue-gif.o(.text+0x2c4):cl-gd-glue-gif.c: undefined reference to `fclose'
> cl-gd-glue-gif.o(.text+0x2d4):cl-gd-glue-gif.c: undefined reference to `__errno'
> cl-gd-glue-gif.o(.text+0x302):cl-gd-glue-gif.c: undefined reference to `fopen'
> cl-gd-glue-gif.o(.text+0x316):cl-gd-glue-gif.c: undefined reference to `gdImageCreateFromXbm'
> cl-gd-glue-gif.o(.text+0x33c):cl-gd-glue-gif.c: undefined reference to `fclose'
> cl-gd-glue-gif.o(.text+0x34c):cl-gd-glue-gif.c: undefined reference to `__errno'
This may come a bit too late but I had some spare hours today and
managed to build GD with MingW. I rebuilt it with __cdecl instead of
__stdcall and put the code of cl-gd-glue-gif.c (with the proper
declarations) directly into gd.c. (Some fiddling was needed because
the configure script didn't find the freetype library although it was
there but basically it worked fine.) The result is here:
<http://weitz.de/files/cl-gd-glue.dll>
This is based on GD 2.0.33 and works fine for me with AllegroCL 6.2
trial and LispWorks 4.3.7 pro on Windows XP pro SP2.
In order to use it you should do the following:
1. Download the file from above and put it into the CL-GD folder.
2. Download all the necessary support libs from the GnuWin32 project -
see <http://gnuwin32.sourceforge.net/> - and put the corresponding
DLLs into the folder where your Lisp image starts up (or somewhere
else where your FFI will find them).
3. No need to download bgd.dll (the GD library) itself because it's
already part of cl-gd-glue.dll.
4. (push :cl-gd-gif *features*)
in order to get GIF support (which is compiled into the DLL).
5. Compile and load CL-GD, make sure to remove old FASL files in case
you had previously built CL-GD without GIF support.
That's it. If you run the tests you'll see three failed tests but no
error messages. This is OK - see the CL-GD documentation for details.
Let me know if this works for you. If I'm not the only one who
succeeds with this setup I'll update the CL-GD docs accordingly.
Cheers,
Edi.
Hi!
On Fri, 20 Aug 2004 19:00:42 +0200, Lam <lam(a)no-log.org> wrote:
> i try to use your great software cl-gd
> i have a question about size of image
>
> i use your example :
>
>> (defun test ()
>> (cl-gd:with-image* (800 800) ; create 200x200 pixel image
>> (cl-gd:allocate-color 68 70 85) ; background color
>> (let ((beige (cl-gd:allocate-color 222 200 81))
>> (brown (cl-gd:allocate-color 206 150 75))
>> (green (cl-gd:allocate-color 104 156 84))
>> (red (cl-gd:allocate-color 163 83 84))
>> (white (cl-gd:allocate-color 255 255 255))
>> (two-pi (* 2 pi)))
>> ;; move origin to center of image
>> (cl-gd:with-transformation (:x1 -100 :x2 100 :y1 -100 :y2 100
>> :radians t)
>> ;; draw some 'pie slices'
>> (cl-gd:draw-arc 0 0 130 130 0 (* .6 two-pi)
>> :center-connect t :filled t :color beige)
>> (cl-gd:draw-arc 0 0 130 130 (* .6 two-pi) (* .8 two-pi)
>> :center-connect t :filled t :color brown)
>> (cl-gd:draw-arc 0 0 130 130 (* .8 two-pi) (* .95 two-pi)
>> :center-connect t :filled t :color green)
>> (cl-gd:draw-arc 0 0 130 130 (* .95 two-pi) two-pi
>> :center-connect t :filled t :color red)
>> (cl-gd:with-default-color (white)
>> (cl-gd:with-default-font (:small)
>> (cl-gd:draw-string -8 -30 "60%")
>> (cl-gd:draw-string -20 40 "20%")
>> (cl-gd:draw-string 20 30 "15%"))
>> ;; (cl-gd:draw-freetype-string -90 75 "Global Revenue"
>> ;; ;; this assumes that
>> 'DEFAULT_FONTPATH'
>> ;; ;; is set correctly
>> ;; :font-name "verdanab"))))
>> )))
>> (cl-gd:write-image-to-file "/tmp/test.png"
>> :compression-level 6 :if-exists
>> :supersede)))
>
> i have modifed window's size to 800
> it's ok for the image, but why arc's size is larger than is your
> example with size equal to 200 ?
Because of the WITH-TRANSFORMATION macro.
<http://weitz.de/cl-gd/#with-transformation>
> how can i modify only image's size, not arc size ?
Sure, but then you'd have to change the code to use absolute
coordinates.
> sorry to send your this mail, but this mail isn't my current mail,
> and i have not subscribed to the ml with this mail
It'd be nice if you could send further questions to the mailing
list. Thanks.
Cheers,
Edi.
Date: Wed, 19 May 2004 07:26:57 +0200
Reply-to: edi(a)agharta.de
User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (gnu/linux)
Hi!
A new release is available from
<http://weitz.de/files/cl-gd.tgz>.
Here's the relevant part from the changelog:
Version 0.4.1
2004-05-21
Fix for memory leak (see WITH-SAFE-ALLOC) by Manuel Odendahl
Documented COLOR-COMPONENT which was missing in index.html (thanks to Manuel Odendahl)
Two new functions, COLOR-COMPONENTS and FIND-COLOR-FROM-IMAGE (both by Manuel Odendahl)
Replaced WRITE-BYTE with WRITE-SEQUENCE for LispWorks - see <http://article.gmane.org/gmane.lisp.lispworks.general/1827>
Have fun,
Edi.
Hi!
We are using cl-gd in our bknr web framework, and use cl-gd to scale,
transform and otherwise manipulate images. We had the problem that
sometimes cl-gd would quit on us saying it could not allocate additional
memory, which suggested a memory leak somewhere. After some code
browsing and testing, I found several race conditions in cl-gd, having
to do with the use of UNWIND-PROTECT, which looked like this:
(let* ((c-style (allocate-foreign-object :int length)))
(unwind-protect (yadayada)
(free-foreign-object c-style)))
However, if somehow the stack is unwound just after the call to
ALLOCATE-FOREIGN-OBJECT, C-STYLE will never get freed. I guess the
UNWIND-PROTECT code was taken from uffi (specifically from
with-foreign-object), which has the same problem (but this is another
story). Anyway, while uffi gets fixed to rewrite the above nicely, I
have added the WITH-SAFE-ALLOC to util.lisp:
(defmacro with-safe-alloc ((var alloc free) &rest body)
`(let (,var)
(unwind-protect
(progn (setf ,var ,alloc)
,@body)
(when ,var ,free))))
and sprinkled the code with it (I replaced all occurences of
UNWIND-PROTECT dealing with memory allocation, and quickly browsed the
code for other allocation code, but couldn't find any).
This seems to fix our problems. On another front, I have added the
function COLOR-COMPONENTS, which returns a list of the color copmonents
of a color (we needed this somewhere), and the function
FIND-COLOR-FROM-IMAGE, which tries to FIND-COLOR a color from a source
image inside a new image (to copy colors between images).
(defun color-components (color &key (image *default-image*))
"Returns the color components of COLOR as a list. The components are in the
order red, green, blue, alpha."
(mapcar #'(lambda (c) (color-component c color :image image))
'(:red :green :blue :alpha)))
(defun find-color-from-image (color source-image &key alpha exact hwb
resolve (image *default-image*))
"Returns the color in IMAGE corresponding to COLOR in SOURCE-IMAGE. The
keyword parameters are passed to FIND-COLOR."
(let ((red (color-component :red color :image source-image))
(blue (color-component :blue color :image source-image))
(green (color-component :green color :image source-image))
(alpha (when alpha (color-component :alpha color :image source-image))))
(find-color red green blue :alpha alpha :exact exact :hwb hwb
:resolve resolve :image image)))
I have made a patch file which I'll attach to the mail, and the patched
cl-gd directory can be downloaded from
http://bl0rg.net/~manuel/cl-gd-patched.tar.gz. I have changed index.html
with documentation for the new functions and a documentation for
COLOR-COMPONENT, which was referenced but not included. I have also
added the Makefile we have to produce the .so file (FreeBSD, haven't
checked it on another platform).
Hope this helps :}
Regards, Manuel Odendahl
Hi!
A new release is available from
<http://weitz.de/files/cl-gd.tgz>.
Here's the relevant part from the changelog:
Version 0.3.1
2004-04-25
Two separate C source files (with and without GIF support)
Added note about failed tests
Added hyperdoc support
Added :CL-GD to *FEATURES*
Have fun,
Edi.
Hi!
There's a new release out which adds optional support for the GIF file
format (thanks to Hans Hübner) - but only if the GD library itself
supports GIF files. This is for example the case on non-US FreeBSD
systems. If you don't need GIF support or don't have a version of GD
which can handle GIF there's no need to install the new version.
As always, it's available from
<http://weitz.de/files/cl-gd.tgz>.
Have fun,
Edi.
PS: I'm sending this to cl-gd-announce as well as cl-gd-devel because
I see that the latter list has significantly more subscribers. So,
if you're on both lists you can safely unsubscribe from
cl-gd-announce - it's intended for people who /only/ want the
announcements and nothing else.