From 468869812f3ca230b95cc05ddce686253804e579 Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Tue, 9 Oct 2012 10:34:25 -0500 Subject: [PATCH] support decompressing LZ_IMAGE_TYPE_XXXA images Signed-off-by: Aric Stewart --- display.js | 2 +- lz.js | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/display.js b/display.js index 15d43d3..d3429da 100644 --- a/display.js +++ b/display.js @@ -246,7 +246,7 @@ SpiceDisplayConn.prototype.process_channel_message = function(msg) if (draw_copy.data.src_bitmap.lz_rgb.top_down != 1) this.log_warn("FIXME: Implement non top down support for lz_rgb"); - var source_img = convert_spice_lz_rgb_to_web(canvas.context, + var source_img = convert_spice_lz_to_web(canvas.context, draw_copy.data.src_bitmap.lz_rgb); if (! source_img) { diff --git a/lz.js b/lz.js index 2914c37..4292eac 100644 --- a/lz.js +++ b/lz.js @@ -141,18 +141,26 @@ function lz_rgb32_decompress(in_buf, at, out_buf, type, default_alpha) return encoder - 1; } -function convert_spice_lz_rgb_to_web(context, lz_rgb) +function convert_spice_lz_to_web(context, lz_image) { - var u8 = new Uint8Array(lz_rgb.data); var at; - if (lz_rgb.type != LZ_IMAGE_TYPE_RGB32 && lz_rgb.type != LZ_IMAGE_TYPE_RGBA) + if (lz_image.type === LZ_IMAGE_TYPE_RGB32 || lz_image.type === LZ_IMAGE_TYPE_RGBA) + { + var u8 = new Uint8Array(lz_image.data); + var ret = context.createImageData(lz_image.width, lz_image.height); + + at = lz_rgb32_decompress(u8, 0, ret.data, LZ_IMAGE_TYPE_RGB32, lz_image.type != LZ_IMAGE_TYPE_RGBA); + if (lz_image.type == LZ_IMAGE_TYPE_RGBA) + lz_rgb32_decompress(u8, at, ret.data, LZ_IMAGE_TYPE_RGBA, false); + } + else if (lz_image.type === LZ_IMAGE_TYPE_XXXA) + { + var u8 = new Uint8Array(lz_image.data); + var ret = context.createImageData(lz_image.width, lz_image.height); + lz_rgb32_decompress(u8, 0, ret.data, LZ_IMAGE_TYPE_RGBA, false); + } + else return undefined; - var ret = context.createImageData(lz_rgb.width, lz_rgb.height); - - at = lz_rgb32_decompress(u8, 0, ret.data, LZ_IMAGE_TYPE_RGB32, lz_rgb.type != LZ_IMAGE_TYPE_RGBA); - if (lz_rgb.type == LZ_IMAGE_TYPE_RGBA) - lz_rgb32_decompress(u8, at, ret.data, LZ_IMAGE_TYPE_RGBA, false); - return ret; }