To add image support to fdo-notify, I need an image type. Looking
through Hackage, I didn't find any image library with the following
features:
* Load from a variety of formats (at least PNG and JPG, I'd say)
* Efficient per-pixel access, or a way to dump the image into a
ByteString as a bitmap (I need to serialise them into the protocol's
bitmap format)
Preferably, it should be possible to construct images programmatically too.
Is there really no such library? It would be nice to have something
like a Haskell equivalent of the Python Imaging Library, which is the
de facto standard image library in Python and supports just about
every type of operation on images you could ask for.
Regards,
Max
_______________________________________________
Haskell-Cafe mailing list
Haskel...@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Max> Haskellers, To add image support to fdo-notify, I need an
Max> image type. Looking through Hackage, I didn't find any image
Max> library with the following features: * Load from a variety of
Max> formats (at least PNG and JPG, I'd say) * Efficient per-pixel
Max> access, or a way to dump the image into a ByteString as a
Max> bitmap (I need to serialise them into the protocol's bitmap
Max> format) Preferably, it should be possible to construct images
Max> programmatically too.
Max> Is there really no such library? It would be nice to have
Max> something like a Haskell equivalent of the Python Imaging
Max> Library, which is the de facto standard image library in
Max> Python and supports just about every type of operation on
Max> images you could ask for.
I've found nothing either, having searched recently.
--
Colin Adams
Preston Lancashire
http://hackage.haskell.org/packages/archive/gd/3000.4.0/doc/html/Graphics-GD.html
http://www.libgd.org/Main_Page
But GD itself may not do what you want.
- jeremy
Try AC-EasyRaster-GTK. It's a thin layer over Gtk2hs that I wrote
precisely because it's so fiddly to do bitmapped graphics with Gtk2hs.
(Vector graphics is delightfully easy with Cairo, but bitmap graphics
requires manual bit-twiddling, and lots of simple but non-obvious API
calls.)
In particular, Easy Raster will trivially load and save PNG and JPEG
images, and provide pixel-level read/write functions (either with or
without bounds checks).
What I haven't implemented is access to the underlying pixel array.
There's a function ib_pixmap which will get you the GTK Pixmap object,
from which you can obtain the pixel array. But it's not an IOArray or
STArray or anything like that; it's some other datatype that implements
the MArray class, so it doesn't buy you much. You might as well just use
the pixel read/write functions from Easy Raster and manually iterate all
pixels...
(Another annoying quirk is that Gtk2hs doesn't provide a way to read or
write an image from a handle, only from a real file, so naturally Easy
Raster shares the same limitation.)
Jeremy> There is a partial binding to libgd:
Jeremy> http://hackage.haskell.org/packages/archive/gd/3000.4.0/doc/html/Graphics-GD.html
Jeremy> http://www.libgd.org/Main_Page
Jeremy> But GD itself may not do what you want.
I ended up using this myself, but it is an unsatisfactory compromise
(no support for TIFF - and many other formats, trashes EXIF
information). In my innocence I had imagined that GTK (the GIMP
ToolKit) would provide all the image manipulation facilities that the
GIMP offers. But no.
--
Colin Adams
Preston Lancashire
What about the imlib bindings [1]? The only problem is, that imlib
doesn't provide a functional image type (you'll end up processing the
image in the IO monad), but it works quite well (I used it for my Piet
interpreter, which required basic image processing tasks like a
labelling algorithm).
HTH - Stephan
[1] http://hackage.haskell.org/package/Imlib
--
Früher hieß es ja: Ich denke, also bin ich.
Heute weiß man: Es geht auch so.
- Dieter Nuhr
If all you want to do is load/save images and do pixel I/O on them, you
can completely ignore process_event, wait_event, main_loop, etc. All you
need to do is make sure you call init_system at the start of your program.
(You see the ib_display function? If you want *that* to work properly,
you need to run the GTK event loop, which is what these event-related
functions are all about. If you're not trying to display the image on
screen, you can ignore all that.)
I should probably make the documentation clearer...
Met vriendelijke groet,
Henk-Jan van Tuyl
[1]
http://hackage.haskell.org/packages/archive/wxcore/0.10.13.0/doc/html/Graphics-UI-WXCore-Image.html#v:imageGetPixels
[2]
http://hackage.haskell.org/packages/archive/wxcore/0.10.13.0/doc/html/Graphics-UI-WXCore-Image.html#v%3AimageCreateFromPixelArray
--
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
--
On Sun, 08 Nov 2009 15:34:26 +0100, Max Rabkin <max.r...@gmail.com>
wrote:
http://hackage.haskell.org/package/gd
And, of course, you can improve it, or write a binding to a more
complete library. Or, even better, write a mix between
http://www.libpng.org/pub/png/pngdocs.html
and
http://hackage.haskell.org/package/binary