IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16796


Ignore:
Timestamp:
Mar 4, 2008, 12:17:15 PM (18 years ago)
Author:
eugene
Message:

add option to limit colors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080223/Ohana/src/kapa2/src/CheckVisual.c

    r16011 r16796  
    1414  unsigned long planes[3];
    1515  XPixmapFormatValues *pixmaps;
    16   int Npixmaps;
     16  int Npixmaps, Npixels;
    1717
    1818  if (DEBUG) {
     
    127127
    128128  if (isDynamic) {
     129    Npixels = NPIXELS_DYNAMIC;
     130    if ((N = get_argument (*argc, argv, "-ncolors"))) {
     131      remove_argument(N, argc, argv);
     132      Npixels = atoi (argv[N]);
     133      remove_argument(N, argc, argv);
     134    }
     135
    129136    /* allocate color cells */
    130     ALLOCATE (graphic[0].pixels, unsigned long, NPIXELS_DYNAMIC);
    131     ALLOCATE (graphic[0].cmap,   XColor,        NPIXELS_DYNAMIC);
    132     for (graphic[0].Npixels = NPIXELS_DYNAMIC; graphic[0].Npixels >= 16; graphic[0].Npixels -= 4) {
     137    ALLOCATE (graphic[0].pixels, unsigned long, Npixels);
     138    ALLOCATE (graphic[0].cmap,   XColor,        Npixels);
     139    for (graphic[0].Npixels = Npixels; graphic[0].Npixels >= 16; graphic[0].Npixels -= 4) {
    133140      if (DEBUG) fprintf (stderr, "trying %d colors\n", (int) graphic[0].Npixels);
    134141      if (XAllocColorCells (graphic[0].display, graphic[0].colormap, FALSE, planes, 1, graphic[0].pixels, graphic[0].Npixels)) {
     
    163170    }
    164171  } else {
     172    Npixels = NPIXELS_STATIC;
     173    if ((N = get_argument (*argc, argv, "-ncolors"))) {
     174      remove_argument(N, argc, argv);
     175      Npixels = atoi (argv[N]);
     176      remove_argument(N, argc, argv);
     177    }
     178
    165179    // XXX allocate the unsigned long *pixels here and above
    166     ALLOCATE (graphic[0].pixels, unsigned long, NPIXELS_STATIC);
    167     ALLOCATE (graphic[0].cmap,   XColor,        NPIXELS_STATIC);
    168     graphic[0].Npixels = NPIXELS_STATIC;
     180    ALLOCATE (graphic[0].pixels, unsigned long, Npixels);
     181    ALLOCATE (graphic[0].cmap,   XColor,        Npixels);
     182    graphic[0].Npixels = Npixels;
    169183  }
    170184
Note: See TracChangeset for help on using the changeset viewer.