diff options
author | jsorg71 <jsorg71> | 2006-03-17 01:10:24 +0000 |
---|---|---|
committer | jsorg71 <jsorg71> | 2006-03-17 01:10:24 +0000 |
commit | b91f25deef43cce2d528e2e121dab32941735dea (patch) | |
tree | 0c178b06bfe37acf36675456971d67625e419781 /libxrdp/xrdp_orders.c | |
parent | b475ff2c83299fee8baed228f13a337d25a0fa1f (diff) | |
download | xrdp-proprietary-b91f25deef43cce2d528e2e121dab32941735dea.tar.gz xrdp-proprietary-b91f25deef43cce2d528e2e121dab32941735dea.zip |
bitmap cache v2
Diffstat (limited to 'libxrdp/xrdp_orders.c')
-rw-r--r-- | libxrdp/xrdp_orders.c | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/libxrdp/xrdp_orders.c b/libxrdp/xrdp_orders.c index 7795089e..9585ebcf 100644 --- a/libxrdp/xrdp_orders.c +++ b/libxrdp/xrdp_orders.c @@ -1476,6 +1476,16 @@ xrdp_orders_send_raw_bitmap(struct xrdp_orders* self, int pixel; int e; + if (width > 64) + { + g_printf("error, width > 64\r\n"); + return 1; + } + if (height > 64) + { + g_printf("error, height > 64\r\n"); + return 1; + } e = width % 4; if (e != 0) { @@ -1651,3 +1661,159 @@ xrdp_orders_send_font(struct xrdp_orders* self, out_uint8a(self->out_s, font_char->data, datasize); return 0; } + +/*****************************************************************************/ +/* returns error */ +/* max size width * height * Bpp + 14 */ +int APP_CC +xrdp_orders_send_raw_bitmap2(struct xrdp_orders* self, + int width, int height, int bpp, char* data, + int cache_id, int cache_idx) +{ + int order_flags; + int len; + int bufsize; + int Bpp; + int i; + int j; + int pixel; + int e; + + if (width > 64) + { + g_printf("error, width > 64\r\n"); + return 1; + } + if (height > 64) + { + g_printf("error, height > 64\r\n"); + return 1; + } + e = width % 4; + if (e != 0) + { + e = 4 - e; + } + Bpp = (bpp + 7) / 8; + bufsize = (width + e) * height * Bpp; + xrdp_orders_check(self, bufsize + 14); + self->order_count++; + order_flags = RDP_ORDER_STANDARD | RDP_ORDER_SECONDARY; + out_uint8(self->out_s, order_flags); + len = (bufsize + 6) - 7; /* length after type minus 7 */ + out_uint16_le(self->out_s, len); + i = (((Bpp + 2) << 3) & 0x38) | (cache_id & 7); + out_uint16_le(self->out_s, i); /* flags */ + out_uint8(self->out_s, RDP_ORDER_RAW_BMPCACHE2); /* type */ + out_uint8(self->out_s, width + e); + out_uint8(self->out_s, height); + out_uint16_be(self->out_s, bufsize | 0x4000); + i = ((cache_idx >> 8) & 0xff) | 0x80; + out_uint8(self->out_s, i); + i = cache_idx & 0xff; + out_uint8(self->out_s, i); + for (i = height - 1; i >= 0; i--) + { + for (j = 0; j < width; j++) + { + if (Bpp == 3) + { + pixel = GETPIXEL32(data, j, i, width); + out_uint8(self->out_s, pixel >> 16); + out_uint8(self->out_s, pixel >> 8); + out_uint8(self->out_s, pixel); + } + else if (Bpp == 2) + { + pixel = GETPIXEL16(data, j, i, width); + out_uint8(self->out_s, pixel); + out_uint8(self->out_s, pixel >> 8); + } + else if (Bpp == 1) + { + pixel = GETPIXEL8(data, j, i, width); + out_uint8(self->out_s, pixel); + } + } + for (j = 0; j < e; j++) + { + out_uint8s(self->out_s, Bpp); + } + } + return 0; +} + +/*****************************************************************************/ +/* returns error */ +/* max size width * height * Bpp + 14 */ +int APP_CC +xrdp_orders_send_bitmap2(struct xrdp_orders* self, + int width, int height, int bpp, char* data, + int cache_id, int cache_idx) +{ + int order_flags; + int len; + int bufsize; + int Bpp; + int i; + int lines_sending; + int e; + struct stream* s; + struct stream* temp_s; + char* p; + + if (width > 64) + { + g_printf("error, width > 64\r\n"); + return 1; + } + if (height > 64) + { + g_printf("error, height > 64\r\n"); + return 1; + } + e = width % 4; + if (e != 0) + { + e = 4 - e; + } + make_stream(s); + init_stream(s, 16384); + make_stream(temp_s); + init_stream(temp_s, 16384); + p = s->p; + i = height; + lines_sending = xrdp_bitmap_compress(data, width, height, s, bpp, 16384, + i - 1, temp_s, e); + if (lines_sending != height) + { + free_stream(s); + free_stream(temp_s); + g_printf("error in xrdp_orders_send_bitmap2, lines_sending(%d) != \ +height(%d)\r\n", lines_sending, height); + return 1; + } + bufsize = s->p - p; + Bpp = (bpp + 7) / 8; + xrdp_orders_check(self, bufsize + 14); + self->order_count++; + order_flags = RDP_ORDER_STANDARD | RDP_ORDER_SECONDARY; + out_uint8(self->out_s, order_flags); + len = (bufsize + 6) - 7; /* length after type minus 7 */ + out_uint16_le(self->out_s, len); + i = (((Bpp + 2) << 3) & 0x38) | (cache_id & 7); + i = i | 0x400; + out_uint16_le(self->out_s, i); /* flags */ + out_uint8(self->out_s, RDP_ORDER_BMPCACHE2); /* type */ + out_uint8(self->out_s, width + e); + out_uint8(self->out_s, height); + out_uint16_be(self->out_s, bufsize | 0x4000); + i = ((cache_idx >> 8) & 0xff) | 0x80; + out_uint8(self->out_s, i); + i = cache_idx & 0xff; + out_uint8(self->out_s, i); + out_uint8a(self->out_s, s->data, bufsize); + free_stream(s); + free_stream(temp_s); + return 0; +} |