From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: Can I use 256 grayscale colors? Date: Fri, 13 Jun 1997 20:17:50 +0100 Organization: None Distribution: world Message-ID: References: <5npo2o$k8v$1 AT jaist-news DOT jaist DOT ac DOT jp> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 35 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk SUGANUMA yoshinori writes: >I would like to use 256 grayscale colors with djgpp. >Is it possible? and are there any libraries to do so? The standard VGA card only uses 6 bits of each palette register, which limits you to 64 shades of grey. Many recent SVGA DAC's can be switched to an 8 bit mode, and there is a VESA function to do this (int 0x10, ax=4F08, bl=0 to set, 1 to read, and bh=desired bits per color). This isn't supported on all hardware, though, so you should check the flag in the VESA mode info structure before using it. Of course, writing code that depends on a non-standard feature may not be such a great idea... >I tried allegro2.2 with GFX_ET4000 gfx_mode, but I could only >obtain 64 grayscale colors. >e.g. >set_gfx_mode(GFX_ET4000,640,480,0,0); >for(c=0;c<256;c++){ > pallete[c].r=c; > pallete[c].g=c; > pallete[c].b=c; > >} Allegro just uses the standard VGA format, with the values ranging 0-63. You could just divide each intensity by four, to get 64 scales of grey with each color duplicated four times, or you could try doing a sort of dither by slightly offsetting the three color components, so they wouldn't all be exact greys but you would get more unique shades (it would need some experimenting to find the best values for this, I never tried it myself...) -- Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ Beauty is a French phonetic corruption of a short cloth neck ornament.