1 (***********************************************************************)
3 (* MLTk, Tcl/Tk interface of Objective Caml *)
5 (* Francois Rouaix, Francois Pessaux, Jun Furuse and Pierre Weis *)
6 (* projet Cristal, INRIA Rocquencourt *)
7 (* Jacques Garrigue, Kyoto University RIMS *)
9 (* Copyright 2002 Institut National de Recherche en Informatique et *)
10 (* en Automatique and Kyoto University. All rights reserved. *)
11 (* This file is distributed under the terms of the GNU Library *)
12 (* General Public License, with the special exception on linking *)
13 (* described in file LICENSE found in the Objective Caml source tree. *)
15 (***********************************************************************)
16 (* Delayed global, a.k.a cache&carry *)
29 (* allows Data in options *)
30 let create_photo options =
31 let hasopt = ref None in
35 begin match !hasopt with
36 None -> hasopt := Some (Data s)
37 | Some _ -> raise (Protocol.TkError "two data sources in options")
40 begin match !hasopt with
41 None -> hasopt := Some (File f)
42 | Some _ -> raise (Protocol.TkError "two data sources in options")
47 None -> raise (Protocol.TkError "no data source in options")
50 let tmpfile = Filename.temp_file "img" "" in
51 let oc = open_out_bin tmpfile in
56 | Data s -> File tmpfile
60 let i = Imagephoto.create newopts in
61 (try Sys.remove tmpfile with Sys_error _ -> ());
65 (try Sys.remove tmpfile with Sys_error _ -> ());
68 | Some (File s) -> Imagephoto.create options