[Spice-devel] [PATCH spice-html5] support decompressing LZ_IMAGE_TYPE_XXXA images

Aric Stewart aric at codeweavers.com
Wed Oct 3 12:39:16 PDT 2012


Signed-off-by: Aric Stewart <aric at codeweavers.com>
---
 display.js |    2 +-
 lz.js      |   28 +++++++++++++++++++---------
 2 files changed, 20 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..dc42e3a 100644
--- a/lz.js
+++ b/lz.js
@@ -141,18 +141,28 @@ 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)
-        return undefined;
-
-    var ret = context.createImageData(lz_rgb.width, lz_rgb.height);
+    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_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);
+        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);
+        var i = lz_image.width * lz_image.height * 4;
+        do {ret.data[i--]=0;} while( i > 0);
+        lz_rgb32_decompress(u8, 0, ret.data, LZ_IMAGE_TYPE_RGBA, false);
+    }
+    else
+        return undefined;
 
     return ret;
 }
-- 
1.7.7.5 (Apple Git-26)




More information about the Spice-devel mailing list