From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA29493; Tue, 18 Jun 2002 18:53:31 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA29520 for ; Tue, 18 Jun 2002 18:53:30 +0200 (MET DST) Received: from postfix2-2.free.fr (postfix2-2.free.fr [213.228.0.140]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g5IGrTj00940; Tue, 18 Jun 2002 18:53:29 +0200 (MET DST) Received: from lfs (strasbourg-2-a7-62-147-13-212.dial.proxad.net [62.147.13.212]) by postfix2-2.free.fr (Postfix) with SMTP id 3FFDE5FDE6; Tue, 18 Jun 2002 18:53:28 +0200 (CEST) Date: Tue, 18 Jun 2002 19:01:39 +0200 From: Nicolas FRANCOIS (AKA El Bofo) To: "Jun P.FURUSE" Cc: Caml List Subject: [Caml-list] Re: Problem with Graph module Message-Id: <20020618190139.69122974.nicolas.francois@free.fr> In-Reply-To: <20020618.114831.1025221351.Jun.Furuse@inria.fr> References: <20020617031219.2dd51ec3.nicolas.francois@free.fr> <20020617.152309.424257368.Jun.Furuse@inria.fr> <20020617194701.62f989bf.nicolas.francois@free.fr> <20020618.114831.1025221351.Jun.Furuse@inria.fr> X-Mailer: Sylpheed version 0.7.6 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Le Tue, 18 Jun 2002 11:48:31 +0200 (CEST) "Jun P.FURUSE" a écrit : > I verified that this code prints out "BUG" when X display has less > than 24bits color depth. In such environment, the colour mapping from > Graphics to X is not one-to-one. This means that point_color may not > always return the exact colour which you drew on the screen. > For example, in an X display of 15bpp, the Graphics colour 0xffffff > and 0xf8f8f8 are translated to the same X white colour. > This is also true for the default white background color of Graphics. > point_color returns 0xf8f8f8, not 0xffffff, this is why the above > code prints out "BUG". OK. Now I have this simple problem : I can use Direct Rendering from X with my Voodoo card in 15 bits, and correct color translation in 24 bits. is that right ? > In Camllight, the translation between Caml colour and X colour > performs communication between programs and the X server. Since it is > highly expensive operation, the colour translation of O'Caml Graphics > is rewritten, so that it would never ask the X server about > colours. It improves the speed of colour query impressively. > Unfortunately, the both colour translation code do not return always > the same result. The different behavior of the Nicolas' O'Caml and > Camllight programs can be explained by this difference of colour > translation. Who said computer science is not an exact one ? > I think this does not mean the new colour translation of O'Caml is > buggy. Even in Camllight, the same things can happen, unless the colour > translation is one-to-one. (It happens less, but not never.) > > The important things (which should be noted in graphics.mli) are that > > * you may get different colour index from one you draw, > > * the colour indices predefined in Graphics for the basic colours > such as white, blue, red, etc can be just canonical candidate > indices for them. > > You should not compare these colour indices against the colours > got from the screen. For example, in Nicolas' program, instead of > comparing Graphics.white, we should use the colour index obtained > from the screen at the begining of the program: > > let screen_white = point_color 0 0 > (* this can be different from Graphics.white *) Great. Thanks for the tip. Euh, and what if I have to test several colors ? Oh, yes, here it is : let screen_from_color c = set_color x; plot 0 0; point_color 0 0;; Right ? I'll try it now. \bye, and thanks again. -- Nicolas FRANCOIS http://nicolas.francois.free.fr A TRUE Klingon programmer does NOT comment his code ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners