+ if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) {
+/* Set up colour map */
+ if (cryst->colors && cryst->ncolors && !cryst->no_colors)
+ free_colors(mi->xgwa.screen, cryst->cmap,
+ cryst->colors, cryst->ncolors);
+ if (cryst->colors)
+ (void) free((void *) cryst->colors);
+ cryst->colors = 0;
+ cryst->ncolors = MI_NCOLORS(mi);
+ if (cryst->ncolors < 2)
+ cryst->ncolors = 2;
+ if (cryst->ncolors <= 2)
+ cryst->mono_p = True;
+ else
+ cryst->mono_p = False;
+
+ if (cryst->mono_p)
+ cryst->colors = 0;
+ else
+ cryst->colors = (XColor *) malloc(sizeof (*cryst->colors) * (cryst->ncolors + 1));
+ cryst->cycle_p = has_writable_cells(mi->xgwa.screen, MI_VISUAL(mi));
+ if (cryst->cycle_p) {
+ if (MI_IS_FULLRANDOM(mi)) {
+ if (!NRAND(8))
+ cryst->cycle_p = False;
+ else
+ cryst->cycle_p = True;
+ } else {
+ cryst->cycle_p = cycle_p;
+ }
+ }
+ if (!cryst->mono_p) {
+ if (!(LRAND() % 10))
+ make_random_colormap(mi->xgwa.screen, MI_VISUAL(mi),
+ cryst->cmap, cryst->colors,
+ &cryst->ncolors,
+ True, True, &cryst->cycle_p, True);
+ else if (!(LRAND() % 2))
+ make_uniform_colormap(mi->xgwa.screen, MI_VISUAL(mi),
+ cryst->cmap, cryst->colors,
+ &cryst->ncolors, True,
+ &cryst->cycle_p, True);
+ else
+ make_smooth_colormap(mi->xgwa.screen, MI_VISUAL(mi),
+ cryst->cmap, cryst->colors,
+ &cryst->ncolors,
+ True, &cryst->cycle_p, True);
+ }
+#if 0 /* #### wrong! -jwz */
+ XInstallColormap(display, cryst->cmap);
+#endif
+ if (cryst->ncolors < 2) {
+ cryst->ncolors = 2;
+ cryst->no_colors = True;
+ } else
+ cryst->no_colors = False;
+ if (cryst->ncolors <= 2)
+ cryst->mono_p = True;
+
+ if (cryst->mono_p)
+ cryst->cycle_p = False;
+
+ }