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

  1. #include<graphics.h>
  2. #include<conio.h>
  3.  
  4. main()
  5. {
  6.    int gd = DETECT, gm, max_colors;
  7.    char a[100];
  8.  
  9.    initgraph(&gd,&gm,"C:\\TC\\BGI");
  10.    
  11.    max_colors = getmaxcolor();
  12.  
  13.    sprintf(a,"Maximum number of colors for current graphics mode and driver = %d",max_colors+1);
  14.    outtextxy(0, 40, a);
  15.  
  16.    getch();
  17.    closegraph();
  18.    return 0;
  19. }