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

Jeremy White jwhite at codeweavers.com
Tue Oct 9 06:48:28 PDT 2012


> -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);

           ^^^^^^

Is this really necessary?  Doesn't createImageData purport to create
the images as transparent black already?

Cheers,

Jeremy


More information about the Spice-devel mailing list