caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <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
Date: Tue, 16 Oct 2007 06:28:40 +0900 (JST)	[thread overview]
Message-ID: <20071016.062840.255394361.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <b17e12b30710151154t6f27d5cax977fcdb612b606d3@mail.gmail.com>

From: "Orlin Grigorov" <ogrigorov@gmail.com>

> 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


  parent reply	other threads:[~2007-10-15 21:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-15 18:54 Orlin Grigorov
2007-10-15 19:03 ` [Caml-list] " Adrien
2007-10-15 21:27 ` Christophe Raffalli
2007-10-15 21:28 ` Jacques Garrigue [this message]
2007-10-16 23:00   ` Orlin Grigorov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071016.062840.255394361.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@yquem.inria.fr \
    --cc=ogrigorov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).