File: svg_to_data.ml

package info (click to toggle)
unison-2.51%2B4.11.1 2.51.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 4,636 kB
  • sloc: ml: 34,056; objc: 3,605; ansic: 1,400; makefile: 722; python: 430; sh: 80
file content (17 lines) | stat: -rw-r--r-- 466 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

(*
   Create a bitmap from a svg file, containing raw data suitable to be
   loaded using GdkPixbuf.from_data.

   Usage:
    lablgtk2 svg_data.ml U.svg > /tmp/U.data
*)

let buf = Rsvg.render_from_file Sys.argv.(1)
let _ =
Format.printf "\"";
let s = Gpointer.string_of_region (GdkPixbuf.get_pixels buf) in
for i = 0 to 575 do
  Format.printf "%s" (String.escaped (String.sub s (i * 16) 16));
  if i = 575 then Format.printf "\"@." else Format.printf "\\@. "
done