#include <graphics.h>

int getdisplaycolor( int color );

The getdisplaycolor function is available in the winbgim implementation of BGI graphics. getdisplaycolor is used to get an color that the current actual display device can display.

Return Value
getdisplaycolor(color) returns the color number that will actually be drawn when a program calls putpixel(0, 0, color). This is not always identical to color because some display devices cannot display all possible colors. However, the display color will always be as close as possible to the requested color.

Windows Notes [WIN]
In the winbgim version, the user might set colors to an RGB color. Therefore, the return value from getdisplaycolor might be an ordinary BGI color (integer from 0 to 15) or an RGB color.

See also


/* getdisplaycolor example */ 

#include <graphics.h>

#include <iostream>

using namespace std;

int main(void)


   int r, g, b; // Components of r, g and b for a color.

   int color_request, color_actual;

   /* initialize graphics window */

   initwindow(300, 300);

   /* Get a user-defined color */

   cout << "Please enter amounts of red, green and blue: ";

   cin >> r >> g >> b;

   /* Compute what this color will display as. */

   color_request = COLOR(r, g, b);

   color_actual = getdisplaycolor(color_request);

   if (IS_BGI_COLOR(color_actual))


      cout << "That will display as BGI color number " << color_actual << endl;




       cout << "That color will display on this machine with components:\n"

	    << "Red:   " << RED_VALUE(color_actual)   << '\n'

            << "Green: " << GREEN_VALUE(color_actual) << '\n'

            << "Blue:  " << BLUE_VALUE(color_actual)  << '\n';



Back to index