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=1.2 required=5.0 tests=AWL,HTML_MESSAGE,SPF_NEUTRAL 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 5336EBC6B for ; Mon, 15 Oct 2007 20:54:43 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAOtTE0fRVYT0kmdsb2JhbACCcotVAQEBAQcEBBMWgSkB X-IronPort-AV: E=Sophos;i="4.21,278,1188770400"; d="scan'208";a="18038723" Received: from an-out-0708.google.com ([209.85.132.244]) by mail4-smtp-sop.national.inria.fr with ESMTP; 15 Oct 2007 20:54:42 +0200 Received: by an-out-0708.google.com with SMTP id b15so119801ana for ; Mon, 15 Oct 2007 11:54:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=zfyFunBkkekmKcY1BzsqE72TL1a/2n35W2GdDtoW4FA=; b=rWdAP3gslDmClls92+Aw8UoZbsL7lxx5VnofalZK0hcx0Wio0R6xgMQv1+GPypS1GYwFvrQ17odW0BSUVbiYou4oC6gC+DxOKjWCuFIjjBul5IPPJRYF3/OgTDwtfMZe75lWGS+F+5SsQfX8rCt+YYtM9w2x5bBtfa04iGSRSuo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=mhAOh2C2rgInEzBVmpu63i1ha+CinsmOPTnbSUwXT/AeBl3db4JEyBbLlSuY9lrSd/0KoJ4GEUlcGku2Z1tU2ONuA9gspAHVdPNKX0FMWj1WAZlP2C5LiZxqo/oBDQIXWH5HtKqf+Qi2AkuC9W05xOWe70e6wduNrER6ySOJwm0= Received: by 10.143.36.15 with SMTP id o15mr1689266wfj.1192474480651; Mon, 15 Oct 2007 11:54:40 -0700 (PDT) Received: by 10.142.97.10 with HTTP; Mon, 15 Oct 2007 11:54:40 -0700 (PDT) Message-ID: Date: Mon, 15 Oct 2007 14:54:40 -0400 From: "Orlin Grigorov" To: caml-list@yquem.inria.fr Subject: saving/loading Raw to/from file MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_31238_8819594.1192474480660" X-Spam: no; 0.00; ocaml:01 lablgl:01 camlimages:01 chunks:01 glpix:01 glpix:01 ocaml:01 lablgl:01 camlimages:01 chunks:01 img:98 img:98 height:98 height:98 clearer:01 ------=_Part_31238_8819594.1192474480660 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi. Lately I've been actively seeking help from this message-list, and to be honest, thanks to your advice and suggestions, my work is going really fast! I am extremely grateful, thank you all! So, I've been struggling with something since yesterday: I am doing something in OCaml, which uses the Lablgl module to draw stuff in OpenGL. For some of the things, I have textures (that is, for all the text I do, I pass it through LaTeX to make a PS, then I use ImageMagick's convert to make it as an JPEG, after which I read it in with CamlImages module, and do some transformations on it before finally making an OpenGL texture out of it). The problem is that this is a real slow-down for the start-up of my program. I don't want to give-up LaTeX, because I need to display some equations and stuff, but here's the deal. A huge part of the chunks of text I use are repeating with each program start-up. So, I was thinking to pre-generate the most common ones, and instead of following the lengthy process of going through LaTeX etc, to just load them from binary files. Maybe a little code will make it clearer: let work_image img = let w = img#width and h = img#height in let image = GlPix.create `ubyte ~format:`rgba ~width:w ~height:h in for i = 0 to h - 1 do for j = 0 to w - 1 do let pixel = img#get (w-j-1) i in let red = pixel.r in let green = pixel.g in let blue = pixel.b in let alpha = if (red == 255 && green == 255 && blue == 255) then 0 else 255 in Raw.sets (GlPix.to_raw image) ~pos:(4*(i*w+j)) [| red; green; blue; alpha |] done done; image ;; 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. Please help! Thanks, Orlin ------=_Part_31238_8819594.1192474480660 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi.  Lately I've been actively seeking help from this message-list, and to be honest, thanks to your advice and suggestions, my work is going really fast!   I am extremely grateful, thank you all!

So, I've been struggling with something since yesterday:

I am doing something in OCaml, which uses the Lablgl module to draw stuff in OpenGL.   For some of the things, I have textures (that is, for all the text I do, I pass it through LaTeX to make a PS, then I use ImageMagick's convert to make it as an JPEG, after which I read it in with CamlImages module, and do some transformations on it before finally making an OpenGL texture out of it).

The problem is that this is a real slow-down for the start-up of my program.  I don't want to give-up LaTeX, because I need to display some equations and stuff, but here's the deal.   A huge part of the chunks of text I use are repeating with each program start-up.   So, I was thinking to pre-generate the most common ones, and instead of following the lengthy process of going through LaTeX etc, to just load them from binary files.    Maybe a little code will make it clearer:

let work_image img =
  let w = img#width and h = img#height in
  let image = GlPix.create `ubyte ~format:`rgba ~width:w ~height:h in
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do
      let pixel = img#get (w-j-1) i in
      let red = pixel.r in
      let green = pixel.g in
      let blue = pixel.b in
      let alpha = if (red == 255 && green == 255 && blue == 255) then 0 else 255 in
      Raw.sets (GlPix.to_raw image) ~pos:(4*(i*w+j))  [| red; green; blue; alpha |]
    done
  done;
  image
;;

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.

Please help! 

Thanks,

Orlin
------=_Part_31238_8819594.1192474480660--