summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Sorg <jay.sorg@gmail.com>2014-09-20 19:29:10 -0700
committerJay Sorg <jay.sorg@gmail.com>2014-09-20 19:29:10 -0700
commit2badb31bf207fa2fa9d2060bcc69569b6306b753 (patch)
tree636d37e10e9263bfe11d17f7a53a87315e890442
parentaf0463ca525b3fe36b3d101b40a3a439399cbf53 (diff)
downloadxrdp-proprietary-2badb31bf207fa2fa9d2060bcc69569b6306b753.tar.gz
xrdp-proprietary-2badb31bf207fa2fa9d2060bcc69569b6306b753.zip
big endian fix
-rw-r--r--xrdp/xrdp_bitmap.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/xrdp/xrdp_bitmap.c b/xrdp/xrdp_bitmap.c
index 8265f167..aafc19f2 100644
--- a/xrdp/xrdp_bitmap.c
+++ b/xrdp/xrdp_bitmap.c
@@ -149,15 +149,44 @@ xrdp_bitmap_create_with_data(int width, int height,
struct xrdp_wm *wm)
{
struct xrdp_bitmap *self = (struct xrdp_bitmap *)NULL;
+#if defined(NEED_ALIGN)
+ tintptr data_as_int;
+ int Bpp;
+#endif
self = (struct xrdp_bitmap *)g_malloc(sizeof(struct xrdp_bitmap), 1);
self->type = WND_TYPE_BITMAP;
self->width = width;
self->height = height;
self->bpp = bpp;
- self->data = data;
- self->do_not_free_data = 1;
self->wm = wm;
+#if defined(NEED_ALIGN)
+ data_as_int = (tintptr) data;
+ if (((bpp >= 24) && (data_as_int & 3)) ||
+ (((bpp == 15) || (bpp == 16)) && (data_as_int & 1)))
+ {
+ /* got to copy data here, it's not alligned
+ other calls in this file assume alignment */
+ Bpp = 4;
+ switch (bpp)
+ {
+ case 8:
+ Bpp = 1;
+ break;
+ case 15:
+ Bpp = 2;
+ break;
+ case 16:
+ Bpp = 2;
+ break;
+ }
+ self->data = (char *)g_malloc(width * height * Bpp, 0);
+ g_memcpy(self->data, data, width * height * Bpp);
+ return self;
+ }
+#endif
+ self->data = data;
+ self->do_not_free_data = 1;
return self;
}