Contents Up Previous Next

How can I use more than the basic Windows colours in a 256-colour mode graphics adapter?

Andrew Davison has the following advice for creating a colourmap. Once you have a valid wxColourMap, you need to set the colourmap for the device context and window.

At 12:13 5/06/96 -0400, you wrote:
>This is what I did to set the wxColourMap :
>
>	const int nocol = 256 ;
>
>	unsigned char red[nocol] ;
>	unsigned char blue[nocol] ;
>	unsigned char green[nocol] ;
>
>	int i ;
>	for (i=0 ; i<nocol ; i++){
>		red[i] = i ;
>		green[i] = i ;
>		blue[i] = i ;
>	}
>
>	// wxCM is a wxColourMap
>	wxCM.Create(nocol, red, green, blue) ;
>}
>
>What I do after is wxDC::SetColourMap(&wxCM) with the wxDC's I use.   
>
>I'm not to sure with what values to fill the arrays I pass to ::Create.
>With these values (i.. [0..255]) it didn't change anything.
>
>	If anyone has a clue,
>				Patrick

I would suggest modelling the Netscape colour-cube, which attempts
to evenly divide up the spectrum. 

 Netscape uses only 216 colours plus another 4 for it's logo. How you fill
in the rest is up to you, but under under MSW Windows itself will always steal
20 colors.

Select colours as follows and load them into your wxColourMap. Using
r, g and b values of 0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF respectively.

i.e

  unsigned char r[256], 
  unsigned i = 0;

  for (int r = 0x00; r <= 0xFF; r += 0x33)
      for (int g = 0x00; g <= 0xFF; g += 0x33)
          for (int b = 0x00; b <= 0xFF; b += 0x33)
          {
              red[i] = r;
              green[i] = g;
              blue[i] = b;
              i++;
          }

Given the above scenario it's always likely that your randomly chosen RGB value
will have a close match.

It would be nice of course if WXWINDOWS detected a 256 colour adapter and did
something similar.

Regards.

Andrew Davison