Hello, i want to save the picture generated by ocaml graphics in a file (png or jpeg). Thank you.
+3
A:
I'm going to assume that you are talking about the Graphics
module in ocaml.
You should notice that the Graphics
module isn't for creating and processing images. You can of course call Graphics.dump_image
if you've already gone ahead and wrote something that produces the Graphics.image
type. This will produce a color array array
, where color
is a packed integer in the format, 0xRRGGBB.
After some other conversion functions you should call upon camlimages to produce your image, and there is a code sample from another question.
nlucaroni
2010-02-10 21:11:10
You said "You should notice that the Graphics module isn't for creating and processing images." Could you explain why ?
nax
2010-02-11 16:41:10
It is a platform independent module for manipulating a canvas on screen. The module is linked with native graphic primitives of the OS. That is the limit to the scope of the module. If it included image file format IO (via external libraries) that would be another dependency that they didn't want to include.
nlucaroni
2010-02-11 21:28:26
Ok i've installed camlimage but i don't find any documentation about it.
nax
2010-02-12 20:37:35
You'll have to be more specific; the total of documentation is the website linked and it's examples, the `.mli` files in the installation, and the `doc` folder in the tar ball.
nlucaroni
2010-02-16 16:12:50