You are here

getmaxcolor function

getmaxcolor function returns maximum color value for current graphics mode and driver. Total number of colors available for current graphics mode and driver are ( getmaxcolor() + 1 ) as color numbering starts from zero.

Declaration: int getmaxcolor();

C program of getmaxcolor

#include<graphics.h>
#include<conio.h>

main()
{
   int gd = DETECT, gm, max_colors;
   char a[100];

   initgraph(&gd,&gm,"C:\\TC\\BGI");
   
   max_colors = getmaxcolor();

   sprintf(a,"Maximum number of colors for current graphics mode and driver = %d",max_colors+1);
   outtextxy(0, 40, a);

   getch();
   closegraph();
   return 0;
}