From 3fec6683f3fb3d8354310bb1010511d200752e6c Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Tue, 15 Jan 2008 14:30:34 +0100 Subject: [PATCH 1/1] fix colors on BGR displays --- src/sim/w_x.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/sim/w_x.c b/src/sim/w_x.c index 06d3b9e..3d8dd48 100644 --- a/src/sim/w_x.c +++ b/src/sim/w_x.c @@ -327,28 +327,43 @@ FindXDisplay(Tk_Window tkwin) color->pixel; \ break; \ case 15: \ + if (xd->visual->red_mask == 0x7c00) { \ xd->pixels[i] = \ (((color->red >> (8 + 3)) & 0x1f) << (5 + 5)) | \ (((color->green >> (8 + 2)) & 0x1f) << (5)) | \ (((color->blue >> (8 + 3)) & 0x1f) << (0)); \ + } else { \ + (((color->blue >> (8 + 3)) & 0x1f) << (5 + 5)) | \ + (((color->green >> (8 + 2)) & 0x1f) << (5)) | \ + (((color->red >> (8 + 3)) & 0x1f) << (0)); \ + } \ break; \ case 16: \ + if (xd->visual->red_mask == 0xf800) { \ xd->pixels[i] = \ (((color->red >> (8 + 3)) & 0x1f) << (6 + 5)) | \ (((color->green >> (8 + 2)) & 0x3f) << (5)) | \ (((color->blue >> (8 + 3)) & 0x1f) << (0)); \ + } else { \ + xd->pixels[i] = \ + (((color->blue >> (8 + 3)) & 0x1f) << (6 + 5)) | \ + (((color->green >> (8 + 2)) & 0x3f) << (5)) | \ + (((color->red >> (8 + 3)) & 0x1f) << (0)); \ + } \ break; \ case 24: \ + case 32: \ + if (xd->visual->red_mask == 0xff0000) { \ xd->pixels[i] = \ ((color->red & 0xff) << 16) | \ ((color->green & 0xff) << 8) | \ ((color->blue & 0xff) << 0); \ - break; \ - case 32: \ + } else { \ xd->pixels[i] = \ - ((color->red & 0xff) << 16) | \ + ((color->blue & 0xff) << 16) | \ ((color->green & 0xff) << 8) | \ - ((color->blue & 0xff) << 0); \ + ((color->red & 0xff) << 0); \ + } \ break; \ } \ } \ -- 2.39.5