Newsgroups: comp.os.msdos.djgpp From: pscargill AT cix DOT compulink DOT co DOT uk ("Peter Scargill") Subject: Re: ALLEGRO - 256 shades of grey?? How? Message-ID: Organization: Compulink Information eXchange References: <3 DOT 0 DOT 16 DOT 19971019191838 DOT 35af0f86 AT hem1 DOT passagen DOT se> Date: Wed, 22 Oct 1997 15:24:46 GMT Lines: 65 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I hope this will be the final comment on this extended thread which I;m ashamed to say I started. Thanks to everyone who contributed something useful to the thread, and here is the end result. You CAN'T have more than 64 greys using standard VGA registers, not directly, but you CAN make it look that way. The code below is a combination of my own idea and code from the archives. I have allocated the first 16 colours to be the standard IBM colours, and then allocated 238 shades of grey, using a method taken from the archives of staggering the green and blue somewhat. This works more or less perfectly. There are 2 unallocated colours at the top which I've madce black and white. I have been experimenting with this having read the arguments presented in this thread and I can tell you for sure that not only can you tell the difference between a 16-grey palette and a 256-grey palette but you can also discern the loss of quality when you move down from 256 to 64 shades. The solution below allows you to use other objects in normal vga colours and yet still put up perfectly acceptable grey images. Incidentally, thanks for all the help folks with the BT848 which I may add Brooktree or their new bosses failed to help with at all, providing only the most useless of DOS libraries and offering no support at all, not to mention holding onto some source code. This particular chip can grab images using a restricted palette - yes, you guessed it, colours 16-253 !!! Here's the code, works a treat within Allegro and thanks to everyone for their help. void set_our_palette(void) { int i; RGB rgb; // for the palette // 16 standard vga colors first rgb.r=00; rgb.g=00; rgb.b=00; set_color(0,&rgb); rgb.r=00; rgb.g=00; rgb.b=31; set_color(1,&rgb); rgb.r=00; rgb.g=31; rgb.b=00; set_color(2,&rgb); rgb.r=00; rgb.g=31; rgb.b=31; set_color(3,&rgb); rgb.r=31; rgb.g=00; rgb.b=00; set_color(4,&rgb); rgb.r=31; rgb.g=00; rgb.b=31; set_color(5,&rgb); rgb.r=31; rgb.g=31; rgb.b=00; set_color(6,&rgb); rgb.r=31; rgb.g=31; rgb.b=31; set_color(7,&rgb); rgb.r=15; rgb.g=15; rgb.b=15; set_color(8,&rgb); rgb.r=00; rgb.g=00; rgb.b=63; set_color(9,&rgb); rgb.r=00; rgb.g=63; rgb.b=00; set_color(10,&rgb); rgb.r=00; rgb.g=63; rgb.b=63; set_color(11,&rgb); rgb.r=63; rgb.g=00; rgb.b=00; set_color(12,&rgb); rgb.r=63; rgb.g=00; rgb.b=63; set_color(13,&rgb); rgb.r=63; rgb.g=63; rgb.b=00; set_color(14,&rgb); rgb.r=63; rgb.g=63; rgb.b=63; set_color(15,&rgb); for (i=0;i<253-16;i++) // set 237 shades of grey { rgb.r=rgb.g=rgb.b=i/4; rgb.r+=i&1; rgb.g+=(i&2)>>1; set_color(i+16,&rgb); } rgb.r=rgb.g=rgb.b=0; set_color(254,&rgb); // these two are spare rgb.r=rgb.g=rgb.b=63; set_color(255,&rgb); // } ---------------------------------------- Regards, Pete. Email: pete AT quantech DOT co DOT uk WWW: www.quantech.co.uk