From afcb7a63e312a86d35553349cc33f35bf2cb6dc6 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 26 Jul 2011 13:40:00 -0700 Subject: [PATCH] Fixed paint_bitmap (was not using cx,cy, leading to black rectangles), proper bpp calculations, using SRC instead of OVER for create_bitmap operations. --- protocols/rdp/src/rdp_handlers.c | 34 ++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/protocols/rdp/src/rdp_handlers.c b/protocols/rdp/src/rdp_handlers.c index 45e1216a..6d396d6c 100644 --- a/protocols/rdp/src/rdp_handlers.c +++ b/protocols/rdp/src/rdp_handlers.c @@ -120,7 +120,7 @@ RD_HBITMAP guac_rdp_ui_create_bitmap(rdpInst* inst, int width, int height, uint8 int x, y; int stride; - int bpp = inst->settings->server_depth / 8; + int bpp = (inst->settings->server_depth + 7) / 8; unsigned char* image_buffer; unsigned char* image_buffer_row; @@ -174,7 +174,7 @@ RD_HBITMAP guac_rdp_ui_create_bitmap(rdpInst* inst, int width, int height, uint8 } surface = cairo_image_surface_create_for_data(image_buffer, CAIRO_FORMAT_RGB24, width, height, stride); - guac_send_png(io, GUAC_COMP_OVER, buffer, 0, 0, surface); + guac_send_png(io, GUAC_COMP_SRC, buffer, 0, 0, surface); guac_flush(io); /* Free surface */ @@ -194,41 +194,49 @@ void guac_rdp_ui_paint_bitmap(rdpInst* inst, int x, int y, int cx, int cy, int w int dx, dy; int stride; - int bpp = inst->settings->server_depth / 8; + int bpp = (inst->settings->server_depth + 7) / 8; unsigned char* image_buffer; unsigned char* image_buffer_row; + int data_stride = width * bpp; + unsigned char* data_row = data; + cairo_surface_t* surface; /* Init Cairo buffer */ - stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, width); + stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, cx); image_buffer = malloc(height*stride); image_buffer_row = image_buffer; /* Copy image data from image data to buffer */ - for (dy = 0; dy> 8) & 0xF8) | ((v >> 13) & 0x07); green = ((v >> 3) & 0xFC) | ((v >> 9) & 0x03); @@ -247,7 +255,7 @@ void guac_rdp_ui_paint_bitmap(rdpInst* inst, int x, int y, int cx, int cy, int w } } - surface = cairo_image_surface_create_for_data(image_buffer, CAIRO_FORMAT_RGB24, width, height, stride); + surface = cairo_image_surface_create_for_data(image_buffer, CAIRO_FORMAT_RGB24, cx, cy, stride); guac_send_png(io, GUAC_COMP_OVER, current_surface, x, y, surface); guac_flush(io); @@ -404,7 +412,7 @@ void guac_rdp_ui_memblt(rdpInst* inst, uint8 opcode, int x, int y, int width, in guac_client* client = (guac_client*) inst->param1; rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data; - const guac_layer* current_surface = guac_client_data->current_surface; + const guac_layer* current_surface = guac_client_data->current_surface; GUACIO* io = client->io; if (opcode != 204)