RE: [Algorithms] 256 colour palette
Brought to you by:
vexxed72
From: Sasha P. <sa...@pr...> - 2000-08-30 10:41:57
|
Hi Matt, One way to go is to use so-called "6-6-6" palette, which gives you 6 shades of red, green and blue color. You basically divide 255 by 6, and ~42 is your shade step. This means, colors in your palette are: 0, 0, 0 0, 0, 42 0, 0, 85 (I rounded up here) ... 0, 42, 0 0, 42, 42 0, 42, 85 ... 255, 255, 255 6-6-6 palette takes 216 colors, this is good for Windows as you still have room for standard Windows colors. If you don't care about this, you can use 6-7-6 palette, having 7 shades for green, this takes 252 colors. Such palettes are good because when you need to find nearest palette index for a given 24-bit RGB color, you don't search for the nearest color, instead you calculate it using trivial math: Rindex = R / (255 / 6); Gindex = G / (255 / 6); Bindex = B / (255 / 6); And then something like (Rindex * 6 * 6) + Gindex * 6 + Bindex gives you the palette index. I hope I didn't make any mistakes in math here, but anyway you should get the idea! :) Regards, Sasha Prokhorov. (sa...@pr.../ICQ 4772797) -----Original Message----- From: Matthew Davies [mailto:MD...@ac...] Sent: Wednesday, August 30, 2000 10:40 AM To: Algorithms List (E-mail) Subject: [Algorithms] 256 colour palette Hi, Can any of you guys give me some hints on choosing a decent 256 colour palette so that I can get a nice spread of colours. I need it for a simple 3d game so basically I need to cover common colours and shades thereof. Do any of you have experience in this area. I've had it so easy with 24-bit graphics up until now! :-) Thanks in advance for any help that you might provide. Cheers! Matt Davies Programmer Acclaim Studios, Cheltenham +44 (0) 1242 533682 ICQ: 78711743 |