getmaxcolor
raw OCR
Returns maximum color value that can be passed to the setcolor function.
Defined in header <graphics.h>
Syntax
#include <graphics.h>
int far getmaxcolor(void);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ |
Remarks
getmaxcolor returns the highest valid color value for the current graphics driver and mode that can be passed to setcolor.
For example, on a 256K EGA, getmaxcolor always returns 15, which means that any call to setcolor with a value from 0 to 15 is valid. On a
| CGA in high-resolution mode or on a Hercules monochrome | adapter, |
getmaxcolor returns a value of 1.
Return value
getmaxcolor returns the highest available color value.
See also
Example
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* request autodetection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
char colstr[80];
/* initialize graphics and local variables */
initgraphi&gdriver, &gmode, "");
/* read result of initialization */
errorcode - graphresult();
if (errorcode != grOk) { /* an error occurred */
printf("Graphics error: ls\n", grapherrormsg (errorcode));
printf("Press any key to halt:");
getchO ;
exit(l); /* terminate with an error code */
}
midx = getmaxxO / 2;
midy = getmaxyO / 2;
/* grab the color info, and convert it to a string */
sprintf(colstr, "This mode supports colors 0..%d", getmaxcolorO );
/* display the information */
settext]UStify(CENTER_TEXT, CENTER_TEXT);
outtextxy(midx, midy, colstr);
/* clean up 7
getchO ;
closegraphO
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/graphics.h/getmaxcolor/
· short form /3.1/getmaxcolor/