[comp.sys.sun] Colormap segments whose size is not a power of two

Matthew Landau <mlandau@diamond.bbn.com> (08/09/90)

Okay, I know I saw a note on this subject in Sun-Spots, and I
could have SWORN I'd saved a copy, but . . .

In any case, I seem to recall that someone a couple of months
back posted an article on how to get the low-level colormap
routines in SunView to allow colormap segments whose size is
not a power of two.  Does anyone have a copy of that posting, 
or details on how to do this?  Please reply be email, and I'll
summarize if there are enough requests.

 Matt Landau			Waiting for a flash of enlightenment
 mlandau@bbn.com			  in all this blood and thunder

falk@peregrine.eng.sun.com (Ed Falk) (08/13/90)

In article <1990Aug13.011000.5497@rice.edu> mlandau@diamond.bbn.com (Matthew Landau) writes:

>In any case, I seem to recall that someone a couple of months
>back posted an article on how to get the low-level colormap
>routines in SunView to allow colormap segments whose size is
>not a power of two.  Does anyone have a copy of that posting, 
>or details on how to do this?  Please reply be email, and I'll
>summarize if there are enough requests.

Normally, for reasons better left to historians, the pixwin package
assumes that colormaps are a power of two in length, and limits your write
masks accordingly.  To override this limitation, you add this line:

	pw->pw_clipdata->pwcd_flags |= PWCD_SET_CMAP_SIZE ;

After which, pixwins will let you set any write mask you want, whether or
not it makes sense.  To calculate the maximum reasonable write mask for
any arbitrary colormap length, do

	int i,maxmask ;

	i = len - 1 ;
	maxmask = 1 ;
	while( i ) {
	  i >>= 1 ;
	  maxmask <<= 1 ;
	}
	--maxmask ;

	-ed falk, sun microsystems -- sun!falk, falk@sun.com