7 let buf = String.create (256*256*3)
8 let ic = open_in_bin "image256x256.rgb"
10 really_input ic ~buf:buf ~pos:0 ~len:(256*256*3);
14 let offset = (y * 256 + x) * 3 in
15 (int_of_char buf.[offset ],
16 int_of_char buf.[offset+1],
17 int_of_char buf.[offset+2])
19 (* let id = Thread.create GtkThread.main () *)
21 (* Choose a visual appropriate for RGB *)
24 GtkBase.Widget.set_default_visual (Gdk.Rgb.get_visual ());
25 GtkBase.Widget.set_default_colormap (Gdk.Rgb.get_cmap ())
27 (* We need show: true because of the need of visual *)
28 let window = GWindow.window ~show:true ~width: 256 ~height: 256 ()
30 let visual = window#misc#visual
32 let color_create = Truecolor.color_creator visual
34 let w = window#misc#window
35 let drawing = new GDraw.drawable w
38 window#connect#destroy ~callback:Main.quit;
41 Image.create ~kind: `FASTEST ~visual: visual ~width: 256 ~height: 256
47 let r,g,b = rgb_at x y in
48 Image.put_pixel image ~x: x ~y: y
49 ~pixel: (color_create ~red: (r * 256) ~green: (g * 256) ~blue: (b * 256))
55 drawing#image image ~xsrc:0 ~ysrc:0 ~xdest:0 ~ydest:0 ~width:256 ~height:256
60 window#event#connect#after#expose ~callback: