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.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 3B061BC69 for ; Mon, 15 Oct 2007 23:28:59 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAMh3E0eCNhAB/2dsb2JhbAA X-IronPort-AV: E=Sophos;i="4.21,278,1188770400"; d="scan'208";a="3001371" Received: from kurims.kurims.kyoto-u.ac.jp ([130.54.16.1]) by mail1-smtp-roc.national.inria.fr with ESMTP; 15 Oct 2007 23:28:58 +0200 Received: from localhost (orion [130.54.16.5]) by kurims.kurims.kyoto-u.ac.jp (8.13.8/8.13.8) with ESMTP id l9FLSr4M024040; Tue, 16 Oct 2007 06:28:53 +0900 (JST) Date: Tue, 16 Oct 2007 06:28:40 +0900 (JST) Message-Id: <20071016.062840.255394361.garrigue@math.nagoya-u.ac.jp> To: ogrigorov@gmail.com Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] saving/loading Raw to/from file From: Jacques Garrigue In-Reply-To: References: X-Mailer: Mew version 4.2 on Emacs 22.1 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; glpix:01 byte:01 glpix:01 height:98 caml-list:01 width:97 len:02 len:02 string:02 string:02 garrigue:03 garrigue:03 jacques:03 jacques:03 let:03 From: "Orlin Grigorov" > With "GlPix.to_raw image" I can make the it raw, if that will help. > > The question is, I really need a way to save this "image" in a file, and be > able to recreate it. Once it is raw, you can read it with Raw.gets_string raw ~pos:0 ~len:(Raw.byte_size raw) You can read it back in the same way: let raw = Raw.create `ubyte ~len:(w*h*4) in Raw.sets_string raw ~pos:0 ~len:(w*h*4) s; GlPix.of_raw raw ~format:`rgba ~width:w ~height:h This should be efficient enough. Once you get a string, you know how to do the I/O. Jacques Garrigue