summaryrefslogtreecommitdiffstats
path: root/libxrdp/xrdp_bitmap32_compress.c
diff options
context:
space:
mode:
authorJay Sorg <jay.sorg@gmail.com>2014-06-10 16:25:54 -0700
committerJay Sorg <jay.sorg@gmail.com>2014-06-10 16:25:54 -0700
commit5d495539196d4c9645f50fbb8f685b33ea5c5820 (patch)
treed190afbd4d2276683885f092cd9abcb1938d6329 /libxrdp/xrdp_bitmap32_compress.c
parent547a34cb6c8c75bea5e021b7d5b7385ef481b4ce (diff)
downloadxrdp-proprietary-5d495539196d4c9645f50fbb8f685b33ea5c5820.tar.gz
xrdp-proprietary-5d495539196d4c9645f50fbb8f685b33ea5c5820.zip
work on 32 bit planar bitmap compressor
Diffstat (limited to 'libxrdp/xrdp_bitmap32_compress.c')
-rw-r--r--libxrdp/xrdp_bitmap32_compress.c61
1 files changed, 60 insertions, 1 deletions
diff --git a/libxrdp/xrdp_bitmap32_compress.c b/libxrdp/xrdp_bitmap32_compress.c
index b681d040..b1aaaa9a 100644
--- a/libxrdp/xrdp_bitmap32_compress.c
+++ b/libxrdp/xrdp_bitmap32_compress.c
@@ -19,14 +19,73 @@
* 32 bpp compression
*/
+/*
+RDP 6.0 Bitmap Compression
+http://msdn.microsoft.com/en-us/library/cc241877.aspx
+*/
+
#include "libxrdp.h"
/*****************************************************************************/
+/* returns the number of lines compressed */
int APP_CC
xrdp_bitmap32_compress(char *in_data, int width, int height,
struct stream *s, int bpp, int byte_limit,
int start_line, struct stream *temp_s,
int e)
{
- return 0;
+ int pixel;
+ int *ptr32;
+ char *ptr8;
+ char *alpha_data;
+ char *red_data;
+ char *green_data;
+ char *blue_data;
+ int alpha_bytes;
+ int red_bytes;
+ int green_bytes;
+ int blue_bytes;
+ int iindex;
+ int jindex;
+ int cx;
+ int cy;
+
+ alpha_data = g_malloc(width * height * 4, 0);
+ red_data = alpha_data + width * height;
+ green_data = red_data + width * height;
+ blue_data = green_data + width * height;
+ alpha_bytes = 0;
+ red_bytes = 0;
+ green_bytes = 0;
+ blue_bytes = 0;
+ cx = width;
+ cy = 0;
+
+ /* split planes */
+ while (start_line >= 0)
+ {
+ ptr32 = (int *) (in_data + start_line * width * 4);
+ for (iindex = 0; iindex < width; iindex++)
+ {
+ pixel = *ptr32;
+ ptr32++;
+ alpha_data[alpha_bytes] = pixel >> 24;
+ alpha_bytes++;
+ red_data[red_bytes] = pixel >> 16;
+ red_bytes++;
+ green_data[green_bytes] = pixel >> 8;
+ green_bytes++;
+ blue_data[blue_bytes] = pixel >> 0;
+ blue_bytes++;
+ }
+ start_line--;
+ cy++;
+ }
+ out_uint8(s, 0x20); /* no alpha */
+ out_uint8a(s, red_data, red_bytes);
+ out_uint8a(s, green_data, green_bytes);
+ out_uint8a(s, blue_data, blue_bytes);
+ out_uint8(s, 0x00);
+ g_free(alpha_data);
+ return cy;
}