diff --git a/client/X11/xf_rail.c b/client/X11/xf_rail.c index 9b483423e..f6051c7f4 100644 --- a/client/X11/xf_rail.c +++ b/client/X11/xf_rail.c @@ -21,7 +21,6 @@ #include #include - #include "xf_window.h" #include "xf_rail.h" @@ -120,6 +119,9 @@ void xf_rail_SetWindowIcon(rdpRail* rail, rdpWindow* window, rdpIcon* icon) xfi = (xfInfo*) rail->extra; xfw = (xfWindow*) window->extra; + icon->extra = gdi_icon_convert(icon->entry->bitsColor, NULL, icon->entry->bitsMask, + icon->entry->width, icon->entry->height, icon->entry->bpp, rail->clrconv); + xf_SetWindowIcon(xfi, xfw, icon); } diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index 33045f924..2de350bf8 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -319,7 +319,7 @@ void xf_SetWindowIcon(xfInfo* xfi, xfWindow* window, rdpIcon* icon) long* dstp; uint32* srcp; - if ((icon->big != True) || (icon->entry->bpp != 32)) + if (icon->big != True) return; pixels = icon->entry->width * icon->entry->height; @@ -329,7 +329,7 @@ void xf_SetWindowIcon(xfInfo* xfi, xfWindow* window, rdpIcon* icon) propdata[0] = icon->entry->width; propdata[1] = icon->entry->height; dstp = &(propdata[2]); - srcp = (uint32*) icon->entry->bitsColor; + srcp = (uint32*) icon->extra; for (y = 0; y < icon->entry->height; y++) { diff --git a/include/freerdp/gdi/color.h b/include/freerdp/gdi/color.h index 6a8d75357..76bdb3e00 100644 --- a/include/freerdp/gdi/color.h +++ b/include/freerdp/gdi/color.h @@ -239,6 +239,8 @@ typedef uint8* (*p_gdi_image_convert)(uint8* srcData, uint8* dstData, int width, FREERDP_API uint32 gdi_color_convert(uint32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv); FREERDP_API uint8* gdi_image_convert(uint8* srcData, uint8 *dstData, int width, int height, int srcBpp, int dstBpp, HCLRCONV clrconv); FREERDP_API uint8* gdi_glyph_convert(int width, int height, uint8* data); +FREERDP_API uint8* gdi_image_invert(uint8* srcData, uint8* dstData, int width, int height, int bpp); +FREERDP_API uint8* gdi_icon_convert(uint8* srcData, uint8* dstData, uint8* mask, int width, int height, int bpp, HCLRCONV clrconv); FREERDP_API uint8* gdi_mono_image_convert(uint8* srcData, int width, int height, int srcBpp, int dstBpp, uint32 bgcolor, uint32 fgcolor, HCLRCONV clrconv); #ifdef __cplusplus diff --git a/include/freerdp/rail/rail.h b/include/freerdp/rail/rail.h index 6ec93e192..30894fe18 100644 --- a/include/freerdp/rail/rail.h +++ b/include/freerdp/rail/rail.h @@ -24,6 +24,7 @@ #include #include #include +#include #include typedef struct rdp_rail rdpRail; @@ -42,6 +43,7 @@ struct rdp_rail { void* extra; UNICONV* uniconv; + CLRCONV* clrconv; rdpIconCache* cache; rdpWindowList* list; rdpSettings* settings; diff --git a/libfreerdp-gdi/color.c b/libfreerdp-gdi/color.c index 76fdff86e..5870a961d 100644 --- a/libfreerdp-gdi/color.c +++ b/libfreerdp-gdi/color.c @@ -575,8 +575,74 @@ uint8* gdi_image_convert(uint8* srcData, uint8* dstData, int width, int height, return 0; } -uint8* -gdi_glyph_convert(int width, int height, uint8* data) +uint8* gdi_image_invert(uint8* srcData, uint8* dstData, int width, int height, int bpp) +{ + int y; + uint8* srcp; + uint8* dstp; + int scanline; + + scanline = width * (bpp / 8); + + if (dstData == NULL) + dstData = (uint8*) malloc(width * height * (bpp / 8)); + + dstp = dstData; + srcp = &srcData[scanline * (height - 1)]; + + for (y = height - 1; y >= 0; y--) + { + memcpy(dstp, srcp, scanline); + dstp += scanline; + srcp -= scanline; + } + + return dstData; +} + +uint8* gdi_icon_convert(uint8* srcData, uint8* dstData, uint8* mask, int width, int height, int bpp, HCLRCONV clrconv) +{ + int x, y; + int pixel; + uint8* data; + uint8 bmask; + uint32 pmask; + uint32* icon; + + pixel = 0; + data = gdi_image_invert(srcData, dstData, width, height, bpp); + dstData = gdi_image_convert(data, NULL, width, height, bpp, 32, clrconv); + + free(data); + bmask = mask[pixel]; + icon = (uint32*) dstData; + + if (bpp < 32) + { + for (y = 0; y < height; y++) + { + for (x = 0; x < width; x++) + { + if (pixel % 8 == 0) + bmask = mask[pixel / 8]; + else + bmask <<= 1; + + pmask = (bmask & 0x80) ? 0x00000000 : 0xFF000000; + + *icon++ |= pmask; + + pixel++; + } + } + } + + free(mask); + + return dstData; +} + +uint8* gdi_glyph_convert(int width, int height, uint8* data) { int x, y; uint8 *srcp; diff --git a/libfreerdp-rail/rail.c b/libfreerdp-rail/rail.c index ac03566a6..d15a57e28 100644 --- a/libfreerdp-rail/rail.c +++ b/libfreerdp-rail/rail.c @@ -103,6 +103,7 @@ rdpRail* rail_new(rdpSettings* settings) rail->cache = icon_cache_new(rail); rail->list = window_list_new(rail); rail->uniconv = freerdp_uniconv_new(); + rail->clrconv = (CLRCONV*) xzalloc(sizeof(CLRCONV)); } return rail;