summaryrefslogtreecommitdiffstats
path: root/freerdp1/xrdp-color.c
diff options
context:
space:
mode:
authorLaxmikant Rashinkar <LK.Rashinkar@gmail.com>2012-09-19 20:51:34 -0700
committerLaxmikant Rashinkar <LK.Rashinkar@gmail.com>2012-09-19 20:51:34 -0700
commit1123323fda6d128fb98b0427e0ea5f6a2dc9e632 (patch)
tree3407a3771a069f812554312ce7c36db625139cc2 /freerdp1/xrdp-color.c
parent3cedfae76a2351bc8b1e5bd2ee33bbf8630dbacf (diff)
downloadxrdp-proprietary-1123323fda6d128fb98b0427e0ea5f6a2dc9e632.tar.gz
xrdp-proprietary-1123323fda6d128fb98b0427e0ea5f6a2dc9e632.zip
o moved from GNU General Public License to Apache License, Version 2.0
o applied new coding standards to all .c files o moved some files around
Diffstat (limited to 'freerdp1/xrdp-color.c')
-rw-r--r--freerdp1/xrdp-color.c495
1 files changed, 266 insertions, 229 deletions
diff --git a/freerdp1/xrdp-color.c b/freerdp1/xrdp-color.c
index ef74d1c5..6b99140a 100644
--- a/freerdp1/xrdp-color.c
+++ b/freerdp1/xrdp-color.c
@@ -19,258 +19,295 @@
#include "xrdp-freerdp.h"
-char* APP_CC
-convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
- int width, int height, int* palette)
+char *APP_CC
+convert_bitmap(int in_bpp, int out_bpp, char *bmpdata,
+ int width, int height, int *palette)
{
- char* out;
- char* src;
- char* dst;
- int i;
- int j;
- int red;
- int green;
- int blue;
- int pixel;
-
- if ((in_bpp == 8) && (out_bpp == 8))
- {
- out = (char*)g_malloc(width * height, 0);
- src = bmpdata;
- dst = out;
- for (i = 0; i < height; i++)
+ char *out;
+ char *src;
+ char *dst;
+ int i;
+ int j;
+ int red;
+ int green;
+ int blue;
+ int pixel;
+
+ if ((in_bpp == 8) && (out_bpp == 8))
+ {
+ out = (char *)g_malloc(width * height, 0);
+ src = bmpdata;
+ dst = out;
+
+ for (i = 0; i < height; i++)
+ {
+ for (j = 0; j < width; j++)
+ {
+ pixel = *((tui8 *)src);
+ pixel = palette[pixel];
+ SPLITCOLOR32(red, green, blue, pixel);
+ pixel = COLOR8(red, green, blue);
+ *dst = pixel;
+ src++;
+ dst++;
+ }
+ }
+
+ return out;
+ }
+
+ if ((in_bpp == 8) && (out_bpp == 16))
+ {
+ out = (char *)g_malloc(width * height * 2, 0);
+ src = bmpdata;
+ dst = out;
+
+ for (i = 0; i < height; i++)
+ {
+ for (j = 0; j < width; j++)
+ {
+ pixel = *((tui8 *)src);
+ pixel = palette[pixel];
+ SPLITCOLOR32(red, green, blue, pixel);
+ pixel = COLOR16(red, green, blue);
+ *((tui16 *)dst) = pixel;
+ src++;
+ dst += 2;
+ }
+ }
+
+ return out;
+ }
+
+ if ((in_bpp == 8) && (out_bpp == 24))
+ {
+ out = (char *)g_malloc(width * height * 4, 0);
+ src = bmpdata;
+ dst = out;
+
+ for (i = 0; i < height; i++)
+ {
+ for (j = 0; j < width; j++)
+ {
+ pixel = *((tui8 *)src);
+ pixel = palette[pixel];
+ SPLITCOLOR32(red, green, blue, pixel);
+ pixel = COLOR24RGB(red, green, blue);
+ *((tui32 *)dst) = pixel;
+ src++;
+ dst += 4;
+ }
+ }
+
+ return out;
+ }
+
+ if ((in_bpp == 15) && (out_bpp == 16))
+ {
+ out = (char *)g_malloc(width * height * 2, 0);
+ src = bmpdata;
+ dst = out;
+
+ for (i = 0; i < height; i++)
+ {
+ for (j = 0; j < width; j++)
+ {
+ pixel = *((tui16 *)src);
+ SPLITCOLOR15(red, green, blue, pixel);
+ pixel = COLOR16(red, green, blue);
+ *((tui16 *)dst) = pixel;
+ src += 2;
+ dst += 2;
+ }
+ }
+
+ return out;
+ }
+
+ if ((in_bpp == 15) && (out_bpp == 24))
{
- for (j = 0; j < width; j++)
- {
- pixel = *((tui8*)src);
- pixel = palette[pixel];
+ out = (char *)g_malloc(width * height * 4, 0);
+ src = bmpdata;
+ dst = out;
+
+ for (i = 0; i < height; i++)
+ {
+ for (j = 0; j < width; j++)
+ {
+ pixel = *((tui16 *)src);
+ SPLITCOLOR15(red, green, blue, pixel);
+ pixel = COLOR24RGB(red, green, blue);
+ *((tui32 *)dst) = pixel;
+ src += 2;
+ dst += 4;
+ }
+ }
+
+ return out;
+ }
+
+ if ((in_bpp == 15) && (out_bpp == 15))
+ {
+ return bmpdata;
+ }
+
+ if ((in_bpp == 16) && (out_bpp == 16))
+ {
+ return bmpdata;
+ }
+
+ if ((in_bpp == 16) && (out_bpp == 24))
+ {
+ out = (char *)g_malloc(width * height * 4, 0);
+ src = bmpdata;
+ dst = out;
+
+ for (i = 0; i < height; i++)
+ {
+ for (j = 0; j < width; j++)
+ {
+ pixel = *((tui16 *)src);
+ SPLITCOLOR16(red, green, blue, pixel);
+ pixel = COLOR24RGB(red, green, blue);
+ *((tui32 *)dst) = pixel;
+ src += 2;
+ dst += 4;
+ }
+ }
+
+ return out;
+ }
+
+ if ((in_bpp == 24) && (out_bpp == 24))
+ {
+ out = (char *)g_malloc(width * height * 4, 0);
+ src = bmpdata;
+ dst = out;
+
+ for (i = 0; i < height; i++)
+ {
+ for (j = 0; j < width; j++)
+ {
+ blue = *((tui8 *)src);
+ src++;
+ green = *((tui8 *)src);
+ src++;
+ red = *((tui8 *)src);
+ src++;
+ pixel = COLOR24RGB(red, green, blue);
+ *((tui32 *)dst) = pixel;
+ dst += 4;
+ }
+ }
+
+ return out;
+ }
+
+ if ((in_bpp == 32) && (out_bpp == 24))
+ {
+ return bmpdata;
+ }
+
+ if ((in_bpp == 32) && (out_bpp == 32))
+ {
+ return bmpdata;
+ }
+
+ g_writeln("convert_bitmap: error unknown conversion from %d to %d",
+ in_bpp, out_bpp);
+ return 0;
+}
+
+/*****************************************************************************/
+/* returns color or 0 */
+int APP_CC
+convert_color(int in_bpp, int out_bpp, int in_color, int *palette)
+{
+ int pixel;
+ int red;
+ int green;
+ int blue;
+
+ if ((in_bpp == 1) && (out_bpp == 24))
+ {
+ pixel = in_color == 0 ? 0 : 0xffffff;
+ return pixel;
+ }
+
+ if ((in_bpp == 8) && (out_bpp == 8))
+ {
+ pixel = palette[in_color];
SPLITCOLOR32(red, green, blue, pixel);
pixel = COLOR8(red, green, blue);
- *dst = pixel;
- src++;
- dst++;
- }
+ return pixel;
}
- return out;
- }
- if ((in_bpp == 8) && (out_bpp == 16))
- {
- out = (char*)g_malloc(width * height * 2, 0);
- src = bmpdata;
- dst = out;
- for (i = 0; i < height; i++)
+
+ if ((in_bpp == 8) && (out_bpp == 16))
{
- for (j = 0; j < width; j++)
- {
- pixel = *((tui8*)src);
- pixel = palette[pixel];
+ pixel = palette[in_color];
SPLITCOLOR32(red, green, blue, pixel);
pixel = COLOR16(red, green, blue);
- *((tui16*)dst) = pixel;
- src++;
- dst += 2;
- }
+ return pixel;
}
- return out;
- }
- if ((in_bpp == 8) && (out_bpp == 24))
- {
- out = (char*)g_malloc(width * height * 4, 0);
- src = bmpdata;
- dst = out;
- for (i = 0; i < height; i++)
+
+ if ((in_bpp == 8) && (out_bpp == 24))
{
- for (j = 0; j < width; j++)
- {
- pixel = *((tui8*)src);
- pixel = palette[pixel];
+ pixel = palette[in_color];
SPLITCOLOR32(red, green, blue, pixel);
- pixel = COLOR24RGB(red, green, blue);
- *((tui32*)dst) = pixel;
- src++;
- dst += 4;
- }
+ pixel = COLOR24BGR(red, green, blue);
+ return pixel;
}
- return out;
- }
- if ((in_bpp == 15) && (out_bpp == 16))
- {
- out = (char*)g_malloc(width * height * 2, 0);
- src = bmpdata;
- dst = out;
- for (i = 0; i < height; i++)
+
+ if ((in_bpp == 15) && (out_bpp == 16))
{
- for (j = 0; j < width; j++)
- {
- pixel = *((tui16*)src);
+ pixel = in_color;
SPLITCOLOR15(red, green, blue, pixel);
pixel = COLOR16(red, green, blue);
- *((tui16*)dst) = pixel;
- src += 2;
- dst += 2;
- }
+ return pixel;
}
- return out;
- }
- if ((in_bpp == 15) && (out_bpp == 24))
- {
- out = (char*)g_malloc(width * height * 4, 0);
- src = bmpdata;
- dst = out;
- for (i = 0; i < height; i++)
+
+ if ((in_bpp == 15) && (out_bpp == 24))
{
- for (j = 0; j < width; j++)
- {
- pixel = *((tui16*)src);
+ pixel = in_color;
SPLITCOLOR15(red, green, blue, pixel);
- pixel = COLOR24RGB(red, green, blue);
- *((tui32*)dst) = pixel;
- src += 2;
- dst += 4;
- }
+ pixel = COLOR24BGR(red, green, blue);
+ return pixel;
+ }
+
+ if ((in_bpp == 15) && (out_bpp == 15))
+ {
+ return in_color;
+ }
+
+ if ((in_bpp == 16) && (out_bpp == 16))
+ {
+ return in_color;
}
- return out;
- }
- if ((in_bpp == 15) && (out_bpp == 15))
- {
- return bmpdata;
- }
- if ((in_bpp == 16) && (out_bpp == 16))
- {
- return bmpdata;
- }
- if ((in_bpp == 16) && (out_bpp == 24))
- {
- out = (char*)g_malloc(width * height * 4, 0);
- src = bmpdata;
- dst = out;
- for (i = 0; i < height; i++)
+
+ if ((in_bpp == 16) && (out_bpp == 24))
{
- for (j = 0; j < width; j++)
- {
- pixel = *((tui16*)src);
+ pixel = in_color;
SPLITCOLOR16(red, green, blue, pixel);
- pixel = COLOR24RGB(red, green, blue);
- *((tui32*)dst) = pixel;
- src += 2;
- dst += 4;
- }
+ pixel = COLOR24BGR(red, green, blue);
+ return pixel;
}
- return out;
- }
- if ((in_bpp == 24) && (out_bpp == 24))
- {
- out = (char*)g_malloc(width * height * 4, 0);
- src = bmpdata;
- dst = out;
- for (i = 0; i < height; i++)
+
+ if ((in_bpp == 24) && (out_bpp == 24))
{
- for (j = 0; j < width; j++)
- {
- blue = *((tui8*)src);
- src++;
- green = *((tui8*)src);
- src++;
- red = *((tui8*)src);
- src++;
- pixel = COLOR24RGB(red, green, blue);
- *((tui32*)dst) = pixel;
- dst += 4;
- }
+ return in_color;
}
- return out;
- }
- if ((in_bpp == 32) && (out_bpp == 24))
- {
- return bmpdata;
- }
- if ((in_bpp == 32) && (out_bpp == 32))
- {
- return bmpdata;
- }
- g_writeln("convert_bitmap: error unknown conversion from %d to %d",
- in_bpp, out_bpp);
- return 0;
-}
-/*****************************************************************************/
-/* returns color or 0 */
-int APP_CC
-convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
-{
- int pixel;
- int red;
- int green;
- int blue;
-
- if ((in_bpp == 1) && (out_bpp == 24))
- {
- pixel = in_color == 0 ? 0 : 0xffffff;
- return pixel;
- }
- if ((in_bpp == 8) && (out_bpp == 8))
- {
- pixel = palette[in_color];
- SPLITCOLOR32(red, green, blue, pixel);
- pixel = COLOR8(red, green, blue);
- return pixel;
- }
- if ((in_bpp == 8) && (out_bpp == 16))
- {
- pixel = palette[in_color];
- SPLITCOLOR32(red, green, blue, pixel);
- pixel = COLOR16(red, green, blue);
- return pixel;
- }
- if ((in_bpp == 8) && (out_bpp == 24))
- {
- pixel = palette[in_color];
- SPLITCOLOR32(red, green, blue, pixel);
- pixel = COLOR24BGR(red, green, blue);
- return pixel;
- }
- if ((in_bpp == 15) && (out_bpp == 16))
- {
- pixel = in_color;
- SPLITCOLOR15(red, green, blue, pixel);
- pixel = COLOR16(red, green, blue);
- return pixel;
- }
- if ((in_bpp == 15) && (out_bpp == 24))
- {
- pixel = in_color;
- SPLITCOLOR15(red, green, blue, pixel);
- pixel = COLOR24BGR(red, green, blue);
- return pixel;
- }
- if ((in_bpp == 15) && (out_bpp == 15))
- {
- return in_color;
- }
- if ((in_bpp == 16) && (out_bpp == 16))
- {
- return in_color;
- }
- if ((in_bpp == 16) && (out_bpp == 24))
- {
- pixel = in_color;
- SPLITCOLOR16(red, green, blue, pixel);
- pixel = COLOR24BGR(red, green, blue);
- return pixel;
- }
- if ((in_bpp == 24) && (out_bpp == 24))
- {
- return in_color;
- }
- if ((in_bpp == 32) && (out_bpp == 24))
- {
- return in_color;
- }
- if ((in_bpp == 32) && (out_bpp == 32))
- {
- return in_color;
- }
- g_writeln("convert_color: error unknown conversion from %d to %d",
- in_bpp, out_bpp);
- return 0;
+ if ((in_bpp == 32) && (out_bpp == 24))
+ {
+ return in_color;
+ }
+
+ if ((in_bpp == 32) && (out_bpp == 32))
+ {
+ return in_color;
+ }
+
+ g_writeln("convert_color: error unknown conversion from %d to %d",
+ in_bpp, out_bpp);
+ return 0;
}