336 |
|
static int |
337 |
|
getpixels() /* get the color map */ |
338 |
|
{ |
339 |
+ |
XColor thiscolor; |
340 |
+ |
register int i, j; |
341 |
+ |
|
342 |
|
if (ncolors > 0) |
343 |
< |
return(ncolors); |
343 |
> |
goto donecolors; |
344 |
|
if (ourvisual == DefaultVisual(ourdisplay,ourscreen)) { |
345 |
|
ourmap = DefaultColormap(ourdisplay,ourscreen); |
346 |
|
goto loop; |
366 |
|
else |
367 |
|
return(ncolors = 0); /* failed */ |
368 |
|
} |
369 |
< |
if (ourmap != DefaultColormap(ourdisplay,ourscreen)) { |
370 |
< |
XColor thiscolor; |
368 |
< |
register int i, j; |
369 |
< |
/* reset black and white */ |
370 |
< |
for (i = 0; i < ncolors; i++) { |
369 |
> |
if (ourmap != DefaultColormap(ourdisplay,ourscreen)) |
370 |
> |
for (i = 0; i < ncolors; i++) { /* reset black and white */ |
371 |
|
if (pixval[i] != ourblack && pixval[i] != ourwhite) |
372 |
|
continue; |
373 |
|
thiscolor.pixel = pixval[i]; |
381 |
|
ncolors--; |
382 |
|
i--; |
383 |
|
} |
384 |
– |
} |
384 |
|
XSetWindowColormap(ourdisplay, gwind, ourmap); |
385 |
+ |
donecolors: |
386 |
+ |
#ifdef DEBUG |
387 |
+ |
thiscolor.flags = DoRed|DoGreen|DoBlue; |
388 |
+ |
thiscolor.red = thiscolor.green = thiscolor.blue = 0; |
389 |
+ |
for (i = 0; i < ncolors; i++) { |
390 |
+ |
thiscolor.pixel = pixval[i]; |
391 |
+ |
XStoreColor(ourdisplay, ourmap, &thiscolor); |
392 |
+ |
} |
393 |
+ |
#endif |
394 |
|
return(ncolors); |
395 |
|
} |
396 |
|
|