#include #include #include #include int main(void) { /* select a driver and mode that supports the use */ /* of the setrgbpalette function. */ int gdriver = VGA, gmode = VGAHI, errorcode; struct palettetype pal; int i, ht, y, xmax; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) /* an error occurred */ { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); /* terminate with an error code */ } /* grab a copy of the palette */ getpalette(&pal); /* create gray scale */ for (i=0; i