support decompressing LZ_IMAGE_TYPE_XXXA images

Signed-off-by: Aric Stewart <aric@codeweavers.com>
This commit is contained in:
Aric Stewart 2012-10-09 10:34:25 -05:00 committed by Jeremy White
parent 2e5ef9b93d
commit 468869812f
2 changed files with 18 additions and 10 deletions

View File

@ -246,7 +246,7 @@ SpiceDisplayConn.prototype.process_channel_message = function(msg)
if (draw_copy.data.src_bitmap.lz_rgb.top_down != 1) if (draw_copy.data.src_bitmap.lz_rgb.top_down != 1)
this.log_warn("FIXME: Implement non top down support for lz_rgb"); 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); draw_copy.data.src_bitmap.lz_rgb);
if (! source_img) if (! source_img)
{ {

26
lz.js
View File

@ -141,18 +141,26 @@ function lz_rgb32_decompress(in_buf, at, out_buf, type, default_alpha)
return encoder - 1; 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; 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; 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; return ret;
} }