[Haskell-cafe] Haskell PNG Writer

Andrew Coppin andrewcoppin at btinternet.com
Sun May 4 04:47:31 EDT 2008


Nahuel Rullo wrote:
> Hi list, i am new in Haskell. I need to make images (PNG, JPEG) with
> haskell, if you can give me a tutorial, thanks!
>   

Gtk2hs has the ability to read and write PNG and JPEG images. Have a 
look at the Graphics.UI.Gtk.Gdk.Pixbuf module:

http://www.haskell.org/gtk2hs/docs/gtk2hs-docs-0.9.12/Graphics-UI-Gtk-Gdk-Pixbuf.html

Specifically, look at pixbufNewFromFile and pixbufSave.

If you then take a look at the Graphics.UI.Gtk.Gdk.Drawable module, 
you'll see a bunch of functions for drawing onto a Pixbuf. 
(Alternatively you can use Cairo.) However, if you're trying to draw an 
algorithmically generated set of pixels, you'll probably want to 
manipulate the underlying bitmap directly. This is Not Fun. Take a look 
at the QuickDraw demo to see how it's done...

HTH.



More information about the Haskell-Cafe mailing list