From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: Colors Date: Wed, 11 Feb 1998 19:01:15 +0000 Organization: None Distribution: world Message-ID: References: <887209728 DOT 858627 AT nn1> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 19 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Anders Clerwall writes: >Hi,, I have tried to convert rgb values to a color value in 800x600 >(64k cols) using the formula: (r << 11) | (g << 5) | b; what's >wrong?!.. when I put in for example the rgb values 60,60, 60.. the >pixel on the screen is blue!.. it should be white, no? In a 64k color mode you have 5 bits of red and blue and six bits of green, giving you ranges of 0-31 and 0-63 respectively. Your values of 60, 60, 60 will overflow the red and blue components, and even if you made them smaller the result won't be white because you have only half as much green as the other colors. Also, if any of your input variables are char types you should be careful to cast them so they won't overflow during the shift. -- Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ "Pigs use it for a tambourine" - Frank Zappa