delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/17/09:33:24

From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: ALLEGRO - 256 shades of grey?? How?
Date: 16 Oct 1997 23:53:59 GMT
Organization: Oxford University, England
Lines: 34
Message-ID: <6269en$a32$2@news.ox.ac.uk>
References: <EI61FB DOT 4Bn AT cix DOT compulink DOT co DOT uk>
NNTP-Posting-Host: sable.ox.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Thu, 16 Oct 1997 22:35:35 GMT in comp.os.msdos.djgpp Peter Scargill
(pscargill AT cix DOT compulink DOT co DOT uk) wrote: 

: In 800*600*256 mode, GRX20 lets you set up 256 shades of gray. ALLEGRO in 
: the same mode only lets you set up 64 (then you get them repeated 3 times 
: as the routine uses 6 bits per colour).

: How do I get the full 256 shades of grey. HELP!!!

I expect GRX is lying; the 6 bit limit is imposed by the VGA hardware, not by
Allegro. What GRX does is probably to map strengths 0-3 to strength 0,
strengths 4-7 to strength 1, ...., strngths 252-255 to strength 63. Simply
put, dividing the [0,255] strengths by four to give [0,63]. For example:

PALETTE grey_pal;
int i;

for (i = 0; i < 256; i++)
 grey_pal[i].r = grey_pal[i].g = grey_pal[i].b = i/4;

If you really need 256 distinct colours, you'll have to sacrifice some hue
accuracy and use slightly off-grey colours. If you don't mind this, try
something like:

for (i = 0; i < 256; i++) {
 grey_pal[i].r = grey_pal[i].g = grey_pal[i].b = i/4;
 if (i&1) grey_pal[i].r++;
 if (i&2) grey_pal[i].g++;
}

The hue inaccuracy will be most noticeable on dark colours.

-- 
george DOT foot AT merton DOT ox DOT ac DOT uk

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019