(I'm using ACL on Linux)
--
ricky
rgi...@surfsouth.com
> Are there any libraries for reading and modifying bitmap files?
When I wasn't looking, I did come across some such Common Lisp file
which appeared to do this, but it was not what I was looking for, and so
I just moved on. I think it's out there. Does this help? no.
However, if you understand the format of the particular bitmap you are
trying to read, can't you just read it in, create a data structure, and
then play around with it (i.e. processing, whatever), and then spit it
out? This seems pretty straightforward, esp. if your bitmap format is
ASCII.
What exactly are you trying to do? Do you want a GUI interface for
modifying the bitmaps? Something like the Unix `bitmap' program?
I'd check to see if Garnet or some other GUI CL thing has either what
you're looking for, or libraries to simplify its creation.
dave
David Bakhash wrote:
>
> What exactly are you trying to do? Do you want a GUI interface for
> modifying the bitmaps? Something like the Unix `bitmap' program?
>
Richard> I want to be able to grab a picture like a gif or jpg, convert it to xpm or
Richard> bmp or whatever is convenient, and give it to lisp as an array of pixels.
I think converting the gif or jpeg image to ppm format would make
accessing the image easier from lisp. ppm is basically a pure text
file of small integers representing the RGB values, plus a few more
integers about the image size. (Roughly from memory.)
Paul Graham's ANSI CL book has some simple code to read ppm files, I
think.
Ray
> I want to be able to grab a picture like a gif or jpg, convert it to xpm or
> bmp or whatever is convenient, and give it to lisp as an array of pixels.
Since most image formats are mildly to highly complex (involving
convoluted bit-diddling in the form of compression/decompression,
which often involves patented algorithms, and similarly evil things),
it often pays to avoid dealing with said formats. There are two basic
approaches to do this:
- Use some of the ready-made libraries (like libpng, libjpeg,
libimlib, etc.) via your implementations FFI. This has the
advantage of higher efficiency, but will involve some coding (and
debugging effort), given that FFI bindings to bit-diddling,
call-back based code is not something for the faint of heart.
- Use netpbm or a similar conversion library to convert the original
images on the fly (via sub-processes and pipes) to something much
more palatable, like ASCII ppm, which can be parsed into your Lisp
much more easily... This will likely not be a suitable solution for
applications that are processing images in tight loops, but will
otherwise give you easy access to your pictures...
Binary P(B|G|P)M formats are especially easy to parse, given that
they're essentially just simple blocks of raw pixels plus
dimensions...
Regs, Pierre.
--
Pierre Mai <pm...@acm.org> PGP and GPG keys at your nearest Keyserver
"One smaller motivation which, in part, stems from altruism is Microsoft-
bashing." [Microsoft memo, see http://www.opensource.org/halloween1.html]
"Pierre R. Mai" wrote:
>
> - Use some of the ready-made libraries (like libpng, libjpeg,
> libimlib, etc.) via your implementations FFI. This has the
> advantage of higher efficiency, but will involve some coding (and
> debugging effort), given that FFI bindings to bit-diddling,
> call-back based code is not something for the faint of heart.
>
> - Use netpbm or a similar conversion library to convert the original
> images on the fly (via sub-processes and pipes) to something much
> more palatable, like ASCII ppm, which can be parsed into your Lisp
> much more easily... This will likely not be a suitable solution for
> applications that are processing images in tight loops, but will
> otherwise give you easy access to your pictures...
You will find documentation in
$ACL_HOME/doc/cl/foreign_functions.htm
assuming ACL 5.0+.
Good luck.
Thom
Foreign Function Interface. Basically, dealing with other/inferior
languages. In C, for instance, you specify -l<library> to the
linker, after having specified "extern foobar(...random junk...)" in
your source files. It's slightly more work from Common Lisp, but it
shouldn't have been. In your Allegro CL Trial Edition distribution,
you will find the file .../doc/cl/foreign_functions.htm, which tells
you the whole story on how to interface with C libraries.
#:Erik
--
If this is not what you expected, please alter your expectations.
> I will need the efficiency of the first solution. But what is FFI and how do I
> use it, I don't even know what the letters stand for. (I'm using FranzACL on
> Linux)
Foreign Function Interface, see Chapter 10 of you Allegro user
guide. Essentially you develop functions in a foreign language
(normally, but not necessarily C) which have hooks to allow them to be
loaded into a running LISP image and called as if they were LISP
functions.
You need have a good knowledge of both LISP and your foreign language
of choice, and
- your code won't be trivially portable even between different
releases of ACL
- your code may not be trivially portable between platforms
- your code won't be trivially portable between different CL
implementations
Think carefully before doing this. The idea of piping your images
through a PBM filter looks a lot easier to me.
--
si...@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/
' ' <------- this blank intentionally spaced left
somewhere hard to get at I have code that reads xbm or something like
that.
but the suggestions of convert it to some standard middle format are
probably best.
modifying: you're on your own there. I have a tiny little icon diddler
program I wrote years ago,
now it's in CLIM, just ran it last week (or was it earlier this week?).
you're welcome to the code,
but it only works on monochrome bitmaps. I use it to create icons.
Richard James Panturis Giuly wrote:
> Are there any libraries for reading and modifying bitmap files?
>
> (I'm using ACL on Linux)
-- clint
The hacker who later on wrote XEmacs and Xscreensaver left some CL
code in
<URL:ftp://ftp.cs.cmu.edu/user/ai/lang/lisp/code/impdep/explorer/jwz.tgz>
The files ps-interpreter.lisp, read-x11-raster.lisp and
bit-array-editor.lisp may prove interesting, at least for
archeological purposes.
For gifs you may have luck with Hallvard Trættebergs code in the
CL-HTTP distribution; it's at
<URL:http://wilson.ai.mit.edu/cl-http/contributions/Hallvard/gif.lisp>
In an earlier thread some suggested using existing libraries for C
with the Foreign Functions Interface (FFI). Using the FFI is
described in doc/cl/foreign_functions.htm in your ACL directory.
--
chr
> Clinton Hyde <ch...@bbn.com> writes:
>
> > I've got lisp code to read GIFs. i have not used it in quite a
> > while...I don't know how well it does with color--I was using it for
> > b&w things in 1993
> >
> > Richard James Panturis Giuly wrote:
> >
> > > Are there any libraries for reading and modifying bitmap files?
> > >
> > > (I'm using ACL on Linux)
>
> The hacker who later on wrote XEmacs and Xscreensaver left some CL
>
that hacker is Jamie Zawinski, also the author of Netscape Navigator Version
1 for X. and he does love those screensavers, has for years...
> code in
> <URL:ftp://ftp.cs.cmu.edu/user/ai/lang/lisp/code/impdep/explorer/jwz.tgz>
>
> The files ps-interpreter.lisp, read-x11-raster.lisp and
> bit-array-editor.lisp may prove interesting, at least for
> archeological purposes.
>
gad, I'd forgotten about those. Jamie also did sun-raster and andrew-raster
readers, but like the x11-raster, those are pretty well useless these days
(well, I thought they were useless at the time, too, but I guess he was doing
something with them)...I could swear someone told me about or maybe gave me a
copy of a TIFF reader a couple of years ago, but I can't find it on my
machine...
must admit I did find that "bit-array-editor.lisp" code interesting--check
the author's name. that's about when I remembered writing that stuff :) and
I'd forgotten who helped. that's the original version of what I later
rewrote into the CLIM version I now have. unfortunately, bit-array-ed isn't
very useful without the custom font: what I did was replace the "1" and "0"
glyphs with solid rectangle and empty rectangle. that way when you typed in a
1 or 0 you got the corresponding blob, I wasn't having to draw/manage/index
rectangles...being unable to create/use custom fonts on the PC, I had to go
with the rectangles method, it doesn't quite work as nicely, you have to use
the mouse to change things. I suppose I could do the arrows and keystrokes
again, but I don't use it as often as I did years ago...
oh, wait. bit-array-editor.ast IS the custom font, with a different name. why
did that happen? oh well, it's a LispM font, not usable elsewhere...
>
> For gifs you may have luck with Hallvard Tręttebergs code in the
> CL-HTTP distribution; it's at
> <URL:http://wilson.ai.mit.edu/cl-http/contributions/Hallvard/gif.lisp>
>
> In an earlier thread some suggested using existing libraries for C
> with the Foreign Functions Interface (FFI). Using the FFI is
> described in doc/cl/foreign_functions.htm in your ACL directory.
>
> --
> chr
-- clint
> > The files ps-interpreter.lisp, read-x11-raster.lisp and
> > bit-array-editor.lisp may prove interesting, at least for
> > archeological purposes.
> >
>
> gad, I'd forgotten about those. Jamie also did sun-raster and andrew-raster
> readers, but like the x11-raster, those are pretty well useless these days
> (well, I thought they were useless at the time, too, but I guess he was doing
> something with them)...
> I could swear someone told me about or maybe gave me a
> copy of a TIFF reader a couple of years ago, but I can't find it on my
> machine...
I've had a look at the CL web browser called Closure. It has code for
reading PNG files <URL:http://www.libpng.org/pub/png/>, and appears to
use external apps such as djpeg and gif2png for other bitmap formats.
Closure is at <URL:http://www.uni-karlsruhe.de/~unk6/closure/>, and
its png code resides in closure/src/renderer/png-images.lisp of the
archive. Closure is written for Allegro CL version 5.
--
chr