--- sourceforge.net/trunk/rdesktop/xwin.c 2003/10/29 08:15:02 527 +++ sourceforge.net/trunk/rdesktop/xwin.c 2003/10/30 00:10:32 534 @@ -207,7 +207,7 @@ } #define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); } -#define BSWAP24(x) { x = (((x & 0xff) << 16) | (x >> 16) | ((x >> 8) & 0xff00)); } +#define BSWAP24(x) { x = (((x & 0xff) << 16) | (x >> 16) | (x & 0xff00)); } #define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \ x = (x << 16) | (x >> 16); } @@ -245,7 +245,7 @@ while (out < end) { value = (uint16) g_colmap[*(data++)]; - + if (g_xserver_be) { *(out++) = value >> 8; @@ -268,7 +268,7 @@ while (out < end) { value = g_colmap[*(data++)]; - + if (g_xserver_be) { *(out++) = value >> 16; @@ -408,34 +408,35 @@ } static void -translate16to16(uint16 * data, uint16 * out, uint16 * end) +translate16to16(uint16 * data, uint8 * out, uint8 * end) { + uint16 pixel; uint16 value; - if (g_xserver_be) + while (out < end) { - while (out < end) + pixel = *(data++); + + if (g_host_be) { - value = *data; - BSWAP16(value); - *out = value; - data++; - out++; + BSWAP16(pixel); } - } - else - { - while (out < end) + value = make_colour(split_colour16(pixel)); + + if (g_xserver_be) { - *out = *data; - out++; - data++; + *(out++) = value >> 8; + *(out++) = value; + } + else + { + *(out++) = value; + *(out++) = value >> 8; } } } - static void translate16to24(uint16 * data, uint8 * out, uint8 * end) { @@ -480,7 +481,8 @@ if (g_host_be) { - BSWAP16(pixel)} + BSWAP16(pixel); + } value = make_colour(split_colour16(pixel)); @@ -530,30 +532,59 @@ static void translate24to24(uint8 * data, uint8 * out, uint8 * end) { + uint32 pixel; + uint32 value; + while (out < end) { - *(out++) = (*(data++)); + pixel = *(data++) << 16; + pixel |= *(data++) << 8; + pixel |= *(data++); + + value = make_colour(split_colour24(pixel)); + + if (g_xserver_be) + { + *(out++) = value >> 16; + *(out++) = value >> 8; + *(out++) = value; + } + else + { + *(out++) = value; + *(out++) = value >> 8; + *(out++) = value >> 16; + } } } static void translate24to32(uint8 * data, uint8 * out, uint8 * end) { + uint32 pixel; + uint32 value; + while (out < end) { + pixel = *(data++) << 16; + pixel |= *(data++) << 8; + pixel |= *(data++); + + value = make_colour(split_colour24(pixel)); + if (g_xserver_be) { - *(out++) = 0x00; - *(out++) = *(data++); - *(out++) = *(data++); - *(out++) = *(data++); + *(out++) = value >> 24; + *(out++) = value >> 16; + *(out++) = value >> 8; + *(out++) = value; } else { - *(out++) = *(data++); - *(out++) = *(data++); - *(out++) = *(data++); - *(out++) = 0x00; + *(out++) = value; + *(out++) = value >> 8; + *(out++) = value >> 16; + *(out++) = value >> 24; } } } @@ -591,8 +622,7 @@ translate16to24((uint16 *) data, out, end); break; case 16: - translate16to16((uint16 *) data, (uint16 *) out, - (uint16 *) end); + translate16to16((uint16 *) data, out, end); break; } break; @@ -700,8 +730,8 @@ g_visual = vi.visual; g_owncolmap = False; - calculate_shifts(vi.red_mask, &g_red_shift_r, &g_red_shift_l); - calculate_shifts(vi.blue_mask, &g_blue_shift_r, &g_blue_shift_l); + calculate_shifts(vi.red_mask, &g_red_shift_r, &g_red_shift_l); + calculate_shifts(vi.blue_mask, &g_blue_shift_r, &g_blue_shift_l); calculate_shifts(vi.green_mask, &g_green_shift_r, &g_green_shift_l); } @@ -821,7 +851,7 @@ #define NULL_POINTER_MASK "\x80" #define NULL_POINTER_DATA "\x0\x0\x0" - + BOOL ui_create_window(void) { @@ -916,7 +946,7 @@ ui_destroy_window(void) { ui_destroy_cursor(g_null_cursor); - + if (g_IC != NULL) XDestroyIC(g_IC);