Grimage is a library that enables reading, writing, and drawing
images in Caml Light. It handles the BMP
and
PPM
formats. A special extension to the PPM
format allows the manipulation of images with transparent areas in them.
It is freely available via FTP and HTTP.
High level interface with the Grimage library uses a generic image
format named grimage
. Images are converted to and from the
grimage
format, and then read and written to the file
system.
Grimage handles the following formats:
BMP
: use
grimage__load_bmp_grimage filename
to load a
BMP
image.
grimage__save_bmp_grimage filename grim
to save a
grimage
image as a BMP
image.
grimage__draw_grimage grim x y
to draw a
BMP
image loaded as a grimage
value.
grimage__image_of_grimage
to convert a
grimage
to an image of the Graphics module.
PPM
(portable pixmaps): files with extension
ppm
, pgm
(portable graymap), or
pbm
(portable bitmap). As for the BMP
format, you may use the corresponding functions from the Grimage
module:
grimage__load_ppm_grimage filename
to load a
PPM
image.
grimage__save_ppm_grimage filename ppm
to save
a grimage
image as a PPM
image.
grimage__draw_grimage grim x y
to draw a
PPM
image loaded as a grimage
value.
grimage__image_of_grimage
to convert to an image
of the Graphics module.
Elementary facilities to transform pixmaps (a color image represented as a matrix of R, G, B values) are provided by Grimage:
pixmap__bitmap_of_pixmap : int -> int -> pixmap
-> pixmap
maps a pixmap into a bitmap image.
pixmap__set_background_transp : pixmap -> unit
sets to
transparent the pixels of a pixmap whose color is the background color.
Low level use of the library is still possible via direct calls to
functions from the Bmp
and Ppm
modules.
For more info about the library, read the interfaces of the modules
and have a look to the test
directory for working examples.
Enjoy Grimage
!
Pierre weis.