Browse thread
[Caml-list] Graphics without open_graph?
-
José Manuel Nunes
-
Jun P.FURUSE
- Gerd Stolpmann
-
Jun P.FURUSE
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Gerd Stolpmann <info@g...> |
| Subject: | Re: [Caml-list] Graphics without open_graph? |
On 2002.05.02 12:44 Jun P.FURUSE wrote:
> Hello,
>
> > I've written a caml-top program whose output includes graphics generated
> > via Graphics module and camlimages.
> > I'm making this program accessible through a web site and I would like
> > to also include the graphic output. The problem is that the program will
> > be running non-interactive under a non graphic environment.
> > So the question is: would it be possible to use the same graphics code?
> > what to adapt?
>
> I guess that you want to use drawing functions (lines, circles...)
> available inside Graphics, without opening the graphic window, and
> obtain results as some graphic file format.
>
> If my guess is correct, unfortunatelly, the drawing function of the
> Graphics library highly depends on those of the window system (X on
> Unix, for example). Using these functions without windowing systems is
> impossible at this moment.
I suppose it will never be possible, because the drawing functions simply
call the drawing primitives of the windowing system.
One way out would be a virtual X11 server that is not connected to any
hardware device but has a "screen" that only exists in memory (e.g.
http://www.xfree.org/4.2.0/Xvfb.1.html). A quick test shows that it really
works:
$ Xvfb :1 -screen 0 32x32x8 -nolisten tcp -ac &
$ ocaml
Objective Caml version 3.04
# #load "graphics.cma";;
# open Graphics;;
# open_graph ":1 50x50";;
- : unit = ()
# fill_circle 25 25 25;;
- : unit = ()
# let img = get_image 0 0 50 50;;
val img : Graphics.image = <abstr>
# dump_image img;;
- : Graphics.color array array =
[|[|16777215; 16777215; ... |]|]
Note that the window is even bigger (50x50 pixels) than the server screen
(32x32 pixels).
The memory requirements of the virtual server seem to be moderate, but I don't
know what happens in the long turn.
Maybe this is an option for you.
Gerd
--
----------------------------------------------------------------------------
Gerd Stolpmann Telefon: +49 6151 997705 (privat)
Viktoriastr. 45
64293 Darmstadt EMail: gerd@gerd-stolpmann.de
Germany
----------------------------------------------------------------------------
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners