Microsoft KB Archive/25643

INF: Setting Palette Colors PSS ID Number: Q25643 Article last modified on 02-11-1992 PSS database name: S_QuickC

1.00 1.01 2.00 2.01 2.50 2.51

MS-DOS

Summary:

The following program sets the video mode to _MRES4COLOR(320x200 pixels, 4 color), then cycles through background colors and palette combinations.

Sample Code
/* Compile options needed: /link graphics.lib */


 * 1) include  #include  long bkcolor[8] = {_BLACK, _BLUE, _GREEN, _CYAN, _RED, _MAGENTA, _BROWN, _WHITE};

char *bkcolor_name [] = {&quot;_BLACK“,”_BLUE“,”_GREEN“,”_CYAN“,”_RED“,”_MAGENTA“,”_BROWN“,”_WHITE&quot;};

main { int i, j, k, delay; _setvideomode (_MRES4COLOR); /* uses CGA color mode */ for (i=0; i<= 3; i++) { _selectpalette (i); for (k=0; k <= 7; k++) { _setbkcolor (bkcolor[k]); for (j=0; j<=3; j++) { _settextposition (1,1); printf (“background color: %8s”, bkcolor_name[k]); printf (“palette: %d: %d”,i,j); _setcolor (j); _rectangle (_GFILLINTERIOR,160,100,320,200); for (delay=0; delay <= 20000; delay++) ; } } } _setvideomode (_DEFAULTMODE); }

Additional reference words: 2.00 2.01 2.50 2.51

Copyright Microsoft Corporation 1992.