Article View: comp.sys.mac
Article #1693Re: Mac II Palettes
From: Rick Holzgrafe
Date: Wed, 12 Jul 1989 01:17
Date: Wed, 12 Jul 1989 01:17
35 lines
2039 bytes
2039 bytes
In article <635@sys.uea.ac.uk> swc@sys.uea.ac.uk (S.W. Cox CMP Staff)
writes:
> The RGB colour entries in Mac II's palettes are supposed to be 0 - 65535
> but when converted to the conventional range 0 .. 1 by:
>
> newcol.red := col.red/65535 etc
>
> where newcol.red, green and blue are reals, it starts inserting negative
> numbers (possibly -32767 to 32767 or something similar).
>
> Can anybody think of a suitable assignment for going from the integers
> to the reals (and vice versa) apart from adding and subtracting 32767
etc.
>
> Thanks, S Cox UEA Norwich, UK
Paraphrase from Inside Mac V-175 (The Color Picker Package):
RGBcolor fields are of type INTEGER, which is signed. There is another
16-bit type called SmallFract of range 0..65535 which is assignment-
compatible with INTEGERs. There are two conversion routines:
FUNCTION SmallFract2Fix(s: SmallFract): Fixed;
FUNCTION Fix2SmallFract(f: Fixed): SmallFract;
So perhaps this will work for you:
newcol.red := SmallFract2Fix(col.red);
where newcol.red is of type Fixed rather than Real. I haven't tried this,
but I will soon because I have a similar problem.
==========================================================================
Rick Holzgrafe | {sun,voder,nsc,mtxinu,dual}!apple!rmh
Software Engineer | AppleLink HOLZGRAFE1 rmh@apple.com
Apple Computer, Inc. | "All opinions expressed are mine, and do
20525 Mariani Ave. MS: 27-O | not necessarily represent those of my
Cupertino, CA 95014 | employer, Apple Computer Inc."
Technical Details
Message-ID:
<2773@internal.Apple.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!brutus.cs.uiuc.edu!apple!apple.com!rmhReferences:
<635@sys.uea.ac.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!brutus.cs.uiuc.edu!apple!apple.com!rmh From: rmh@apple.com (Rick Holzgrafe) Newsgroups: comp.sys.mac,comp.sys.mac.programmer Subject: Re: Mac II Palettes Message-ID: <2773@internal.Apple.COM> Date: 12 Jul 89 01:17:16 GMT References: <635@sys.uea.ac.uk> Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 35