summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJavier Celaya <javier.celaya@flexvm.es>2015-01-28 11:49:46 +0100
committerChristophe Fergeau <cfergeau@redhat.com>2015-02-03 10:43:31 +0100
commitf76fc28fc54200e1302ca6ffd289d9fc829cc272 (patch)
treebc034a965752bb3dd2782cd7efcf8183b8db05b7 /common
parent83c0d642edd0126df14a7fc4881412be2ad55e15 (diff)
LZ4: Decode the image format from the stream
Diffstat (limited to 'common')
-rw-r--r--common/canvas_base.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/common/canvas_base.c b/common/canvas_base.c
index d5bd9d0..d621b39 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -527,6 +527,8 @@ static pixman_image_t *canvas_get_lz4(CanvasBase *canvas, SpiceImage *image)
uint8_t *dest, *data, *data_end;
int width, height, top_down;
LZ4_streamDecode_t *stream;
+ uint8_t spice_format;
+ pixman_format_code_t format;
spice_chunks_linearize(image->u.lz4.data);
data = image->u.lz4.data->chunk[0].data;
@@ -534,12 +536,28 @@ static pixman_image_t *canvas_get_lz4(CanvasBase *canvas, SpiceImage *image)
width = image->descriptor.width;
height = image->descriptor.height;
top_down = *(data++);
+ spice_format = *(data++);
+ switch (spice_format) {
+ case SPICE_BITMAP_FMT_16BIT:
+ format = PIXMAN_x1r5g5b5;
+ break;
+ case SPICE_BITMAP_FMT_24BIT:
+ case SPICE_BITMAP_FMT_32BIT:
+ format = PIXMAN_x8r8g8b8;
+ break;
+ case SPICE_BITMAP_FMT_RGBA:
+ format = PIXMAN_a8r8g8b8;
+ break;
+ default:
+ spice_warning("Unsupported bitmap format %d with LZ4\n", spice_format);
+ return NULL;
+ }
surface = surface_create(
#ifdef WIN32
canvas->dc,
#endif
- PIXMAN_a8r8g8b8,
+ format,
width, height, top_down);
if (surface == NULL) {
spice_warning("create surface failed");