From 537280f183d3a35e8dee8a20238c71e7440cb28c Mon Sep 17 00:00:00 2001 From: Yonit Halperin Date: Sun, 20 Jun 2010 17:18:56 +0300 Subject: Lossy compression of RGBA images (on WAN connection) The RGB channels are compressed using JPEG. The alpha channel is compressed using LZ. --- common/lz.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'common/lz.c') diff --git a/common/lz.c b/common/lz.c index 73a797c7..e5635849 100644 --- a/common/lz.c +++ b/common/lz.c @@ -565,6 +565,9 @@ int lz_encode(LzContext *lz, LzImageType type, int width, int height, int top_do lz_rgb32_compress(encoder); lz_rgb_alpha_compress(encoder); break; + case LZ_IMAGE_TYPE_XXXA: + lz_rgb_alpha_compress(encoder); + break; case LZ_IMAGE_TYPE_INVALID: default: encoder->usr->error(encoder->usr, "bad image type\n"); @@ -661,6 +664,7 @@ void lz_decode(LzContext *lz, LzImageType to_type, uint8_t *buf) case LZ_IMAGE_TYPE_RGB24: case LZ_IMAGE_TYPE_RGB32: case LZ_IMAGE_TYPE_RGBA: + case LZ_IMAGE_TYPE_XXXA: case LZ_IMAGE_TYPE_INVALID: default: encoder->usr->error(encoder->usr, "bad image type\n"); @@ -705,6 +709,14 @@ void lz_decode(LzContext *lz, LzImageType to_type, uint8_t *buf) encoder->usr->error(encoder->usr, "unsupported output format\n"); } break; + case LZ_IMAGE_TYPE_XXXA: + if (encoder->type == to_type) { + alpha_size = lz_rgb_alpha_decompress(encoder, (rgb32_pixel_t *)buf, size); + out_size = alpha_size; + } else { + encoder->usr->error(encoder->usr, "unsupported output format\n"); + } + break; case LZ_IMAGE_TYPE_PLT1_LE: case LZ_IMAGE_TYPE_PLT1_BE: case LZ_IMAGE_TYPE_PLT4_LE: -- cgit