-void DoneFigures()
-{
- //free(figures);
- //free(bitmaps);
- delete[] figures;
- delete[] bitmaps;
- figarrsize = 0;
- bmparrsize = 0;
-
- lyxerr.debug() << "Unregistering figures..." << endl;
-
- fl_remove_canvas_handler(figinset_canvas, ClientMessage,
- GhostscriptMsg);
-
- if (gs_color) {
- lyxerr.debug() << "Freeing up the colors..." << endl;
- XFreeColors(fl_display, color_map, gs_pixels,
- gs_num_pixels, 0);
- /******????????????????? what's planes in this case ??????***/
- }
-}
-
-
-int FindBmpIndex(figdata * tmpdata)
-{
- int i = 0;
- while (i < bmpinsref) {
- if (bitmaps[i] == tmpdata) return i;
- ++i;
+ Visual * vi = DefaultVisual(fl_get_display(),
+ DefaultScreen(fl_get_display()));
+ if (lyxerr.debugging()) {
+ printf("Visual ID: %ld, class: %d, bprgb: %d, mapsz: %d\n",
+ vi->visualid, vi->c_class,
+ vi->bits_per_rgb, vi->map_entries);
+ }
+ color_visual = ((vi->c_class == StaticColor) ||
+ (vi->c_class == PseudoColor) ||
+ (vi->c_class == TrueColor) ||
+ (vi->c_class == DirectColor));
+ if ((vi->c_class & 1) == 0) return;
+ // now allocate colors
+ if (vi->c_class == GrayScale) {
+ // allocate grayscale
+ AllocGrays(vi->map_entries/2);
+ } else {
+ // allocate normal color
+ int i = 5;
+ while (i * i * i * 2 > vi->map_entries) --i;
+ AllocColors(i);
+ }
+ gs_allcolors = vi->map_entries;