384 |
|
{ |
385 |
|
if (cmap[0] && cmap[1]) { |
386 |
|
int num = 256; |
387 |
< |
if (vis->c_class == DirectColor && VideoMonitor.mode.depth == VDEPTH_16BIT) |
388 |
< |
num = vis->map_entries; |
387 |
> |
if (IsDirectMode(VideoMonitor.mode)) |
388 |
> |
num = vis->map_entries; // Palette is gamma table |
389 |
> |
else if (vis->c_class == DirectColor) |
390 |
> |
return; // Indexed mode on true color screen, don't set CLUT |
391 |
|
XStoreColors(x_display, cmap[0], palette, num); |
392 |
|
XStoreColors(x_display, cmap[1], palette, num); |
393 |
|
} |
1187 |
|
cmap[0] = XCreateColormap(x_display, rootwin, vis, AllocAll); |
1188 |
|
cmap[1] = XCreateColormap(x_display, rootwin, vis, AllocAll); |
1189 |
|
|
1190 |
< |
// Preset pixel members for gamma table |
1190 |
> |
int num = 256; |
1191 |
|
if (color_class == DirectColor) { |
1192 |
< |
int num = vis->map_entries; |
1192 |
> |
num = vis->map_entries; |
1193 |
> |
|
1194 |
> |
// Preset pixel values for gamma table |
1195 |
|
uint32 rmask = vis->red_mask, gmask = vis->green_mask, bmask = vis->blue_mask; |
1196 |
|
uint32 mask; |
1197 |
|
int rloss = 8, rshift = 0; |
1214 |
|
palette[i].pixel = ((c >> rloss) << rshift) | ((c >> gloss) << gshift) | ((c >> bloss) << bshift); |
1215 |
|
} |
1216 |
|
} |
1217 |
+ |
|
1218 |
+ |
// Load gray ramp |
1219 |
+ |
for (int i=0; i<num; i++) { |
1220 |
+ |
int c = (i * 256) / num; |
1221 |
+ |
palette[i].red = c * 0x0101; |
1222 |
+ |
palette[i].green = c * 0x0101; |
1223 |
+ |
palette[i].blue = c * 0x0101; |
1224 |
+ |
if (color_class == PseudoColor) |
1225 |
+ |
palette[i].pixel = i; |
1226 |
+ |
palette[i].flags = DoRed | DoGreen | DoBlue; |
1227 |
+ |
} |
1228 |
+ |
XStoreColors(x_display, cmap[0], palette, num); |
1229 |
|
} |
1230 |
|
|
1231 |
|
// Get screen mode from preferences |
1408 |
|
|
1409 |
|
// Convert colors to XColor array |
1410 |
|
int num_in = 256, num_out = 256; |
1411 |
< |
if (VideoMonitor.mode.depth == VDEPTH_16BIT) { |
1411 |
> |
if (VideoMonitor.mode.depth == VDEPTH_16BIT) |
1412 |
|
num_in = 32; |
1413 |
+ |
if (IsDirectMode(VideoMonitor.mode)) { |
1414 |
|
// If X is in 565 mode we have to stretch the palette from 32 to 64 entries |
1415 |
< |
if (vis->c_class == DirectColor) |
1399 |
< |
num_out = vis->map_entries; |
1415 |
> |
num_out = vis->map_entries; |
1416 |
|
} |
1417 |
|
XColor *p = palette; |
1418 |
|
for (int i=0; i<num_out; i++) { |