From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=MAILTO_TO_SPAM_ADDR autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id EB5FDBB84 for ; Sun, 21 Sep 2008 21:50:56 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArwDAEZC1khN6B+kjmdsb2JhbACBXZFAAQEBAQkJChqbN4VIgWY X-IronPort-AV: E=Sophos;i="4.32,441,1217800800"; d="scan'208";a="29429540" Received: from discorde.inria.fr ([192.93.2.38]) by mail4-smtp-sop.national.inria.fr with ESMTP; 21 Sep 2008 21:50:56 +0200 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m8LJouvA022675 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Sun, 21 Sep 2008 21:50:56 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArwDAEZC1khN6B+kjmdsb2JhbACBXZFAAQEBAQkJChqbN4VIgWY X-IronPort-AV: E=Sophos;i="4.32,441,1217800800"; d="scan'208";a="29429539" Received: from fe01x03-cgp.akado.ru (HELO akado.ru) ([77.232.31.164]) by mail4-smtp-sop.national.inria.fr with ESMTP; 21 Sep 2008 21:50:55 +0200 Received: from av1474.oops ([10.0.66.9] verified) by fe01-cgp.akado.ru (CommuniGate Pro SMTP 5.1.16) with ESMTPS id 31478421; Sun, 21 Sep 2008 23:50:54 +0400 Date: Sun, 21 Sep 2008 23:50:53 +0400 (MSD) From: malc X-X-Sender: malc@linmac.oyster.ru To: Janne Hellsten Cc: caml-list@inria.fr Subject: Re: [Caml-list] Portable PNG exporter In-Reply-To: <700d600f0809201037x3358a788v818d488c451ce7bf@mail.gmail.com> Message-ID: References: <700d600f0809201037x3358a788v818d488c451ce7bf@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Miltered: at discorde with ID 48D6A5A0.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; malc:01 framebuffer:01 ocaml:01 camlimages:01 ocaml:01 zlib:01 bitmap:01 nativeint:01 printf:01 fprintf:01 wrote:01 ints:01 caml-list:01 int:01 int:01 On Sat, 20 Sep 2008, Janne Hellsten wrote: > Hi list, > > While working on a graphics related problem, I needed to save the > contents of a Graphics framebuffer to a .png file. Quick googling for > "ocaml png" didn't bring up any results for libraries that would be > easy to install via GODI. I am aware of CamlImages but unfortunately > I have never been successful at installing it due its heavy dependence > on external libraries. I also often work on Windows and installing > external OCaml libraries on Windows is usually a major PITA (if > possible at all). > > I decided to write a simple self-contained .png exporter that wouldn't > depend on any external libraries (not even libpng or zlib). I thought > someone else might benefit from this piece of code and I thus made it > freely available here: > > http://code.google.com/p/aihiot/source/browse/trunk/gfx/save_bitmap/ocaml/png.ml Few things that hurt the eye: Int32.of_string "[number]" is unnecessary, OCaml(not sure which version this was introduced in though) can read various specific size ints natively: # 0n, 0l, 0L;; - : nativeint * int32 * int64 = (0n, 0l, 0L) Secondly `Printf.fprintf chnl "string"' looks rather expensive compared to `output_string chnl "string"'. -- mailto:av1474@comtv.ru