# include "Ximage.h"

/************** CheckColors *************/
void CheckColors (Graphic *graphic, int *argc, char **argv) {

  char *temp_name;
  int N;

  /* here we define the values for "black" (blackground) and "white" (whiteground)
     if -fg, or -bg exist, or if Foreground or Background are set in .Xdefaults, 
     use those.  blackground defaults to Black, whiteground defaults to White. */

  graphic[0].black = BlackPixel (graphic[0].display, graphic[0].screen);
  temp_name = XGetDefault (graphic[0].display, argv[0], "Foreground");
  if ((N = get_argument (*argc, argv, "-fg"))) {
    if (N + 1 < *argc) {
      temp_name = argv[N+1];
    } else {
      fprintf (stderr, "error: usage is -fg color\n");
      exit (0);
    }
  }
  if (temp_name != (char *)NULL) 
    graphic[0].black = GetColor (graphic[0].display, temp_name, graphic[0].colormap, graphic[0].black);

  graphic[0].white = WhitePixel (graphic[0].display, graphic[0].screen);
  temp_name = XGetDefault (graphic[0].display, argv[0], "Background");
  if ((N = get_argument (*argc, argv, "-bg"))) {
    if (N + 1 < *argc) {
      temp_name = argv[N+1];
    } else {
      fprintf (stderr, "error: usage is -bg color\n");
      exit (0);
    }
  }  
  if (temp_name != (char *)NULL) 
    graphic[0].white = GetColor (graphic[0].display, temp_name, graphic[0].colormap, graphic[0].white);
 
}

