Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site watmath.UUCP Path: utzoo!watmath!jsgray From: jsgray@watmath.UUCP (Jan Gray) Newsgroups: net.graphics Subject: Re: HELP!! SUN specific graphics question. Message-ID: <11195@watmath.UUCP> Date: Tue, 29-Jan-85 23:52:53 EST Article-I.D.: watmath.11195 Posted: Tue Jan 29 23:52:53 1985 Date-Received: Wed, 30-Jan-85 06:11:14 EST References: <225@eneevax.UUCP> Reply-To: jsgray@watmath.UUCP (Jan Gray) Distribution: net Organization: U of Waterloo, Ontario Lines: 53 Keywords: colour map > From eneevax!phaedrus 24 Jan 85 19:15:43 GMT > .......... And if that isn't possible could someone explain to me how > the following routine (which sets up a colormap) works? I don't quite > understand what all the shifting and the oring does. > > int mak_col_map () > { > int index; > unsigned char red[256], > blue[256], > green[256]; > int r, > b, > g; > > for (b = 0; b < 4; b++) { > for (g = 0; g < 8; g++) { > for (r = 0; r < 8; r++) { > index = (b << 6) | (g << 3) | (r); > blue[index] = b * 84; > red[index] = r * 36; > green[index] = g * 36; > } > } > } > pr_putcolormap (col_mon, 0, 256, red, green, blue); > } It looks like the program is building separate red, green and blue look up tables, each of which has 256 entries and is 8 bits deep. I expect that you have an 8 bit frame buffer, and you set up the internal data paths so that those eight bits index a red, green and blue intensity. The program you include sets up the colour map so that a colour contains two bits of blue, three bits of red, and three bits of green intensity. You therefore can select colours with three levels of blue (plus black) and seven levels of red and green (plus black). (84 == 255 / 3, and 36 == 255 / 7) Colour 0 is 00 000 000 == no blue, no green, no red Colour 1 is 00 000 001 == no blue, no green, 1/7 red (36/255) Colour 2 is 00 000 010 == no blue, no green, 2/7 red (72/255) ... Colour 255 is 11 111 111 == full blue, full green, full red I expect this is a standard trick for 8 bit deep frame buffers with separate rgb lookup tables. I expect too much, Jan Gray (jsgray@watmath.UUCP) University of Waterloo (519) 885-1211 x3870