Skip to content

Commit

Permalink
Fixed GDI color decoding issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
akallabeth committed Feb 1, 2017
1 parent 7c5a2f4 commit df764f5
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 7 deletions.
24 changes: 23 additions & 1 deletion client/X11/xf_graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,29 @@ BOOL xf_decode_color(xfContext* xfc, const UINT32 srcColor, XColor* color)
if (!settings)
return FALSE;

SrcFormat = gdi_get_pixel_format(settings->ColorDepth);
switch (settings->ColorDepth)
{
case 32:
case 24:
SrcFormat = PIXEL_FORMAT_BGR24;
break;

case 16:
SrcFormat = PIXEL_FORMAT_RGB16;
break;

case 15:
SrcFormat = PIXEL_FORMAT_RGB15;
break;

case 8:
SrcFormat = PIXEL_FORMAT_RGB8;
break;

default:
return FALSE;
}

SplitColor(srcColor, SrcFormat, &r, &g, &b, &a, &gdi->palette);
color->blue = (unsigned short)(b << 8);
color->green = (unsigned short)(g << 8);
Expand Down
44 changes: 38 additions & 6 deletions libfreerdp/gdi/gdi.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,41 @@ static const BYTE GDI_BS_HATCHED_PATTERNS[] =
INLINE BOOL gdi_decode_color(rdpGdi* gdi, const UINT32 srcColor,
UINT32* color, UINT32* format)
{
UINT32 SrcFormat = gdi_get_pixel_format(gdi->context->settings->ColorDepth);
UINT32 SrcFormat;
UINT32 ColorDepth;

if (!gdi || !color || !gdi->context || !gdi->context->settings)
return FALSE;

ColorDepth = gdi->context->settings->ColorDepth;

switch (ColorDepth)
{
case 32:
case 24:
SrcFormat = PIXEL_FORMAT_BGR24;
break;

case 16:
SrcFormat = PIXEL_FORMAT_RGB16;
break;

case 15:
SrcFormat = PIXEL_FORMAT_RGB15;
break;

case 8:
SrcFormat = PIXEL_FORMAT_RGB8;
break;

default:
return FALSE;
}

if (format)
*format = SrcFormat;
*format = gdi->dstFormat;

*color = ConvertColor(srcColor, SrcFormat,
gdi->dstFormat, &gdi->palette);
*color = ConvertColor(srcColor, SrcFormat, gdi->dstFormat, &gdi->palette);
return TRUE;
}

Expand All @@ -340,12 +368,12 @@ INLINE DWORD gdi_rop3_code(BYTE code)

UINT32 gdi_get_pixel_format(UINT32 bitsPerPixel)
{
UINT32 format = PIXEL_FORMAT_XBGR32;
UINT32 format;

switch (bitsPerPixel)
{
case 32:
format = PIXEL_FORMAT_ABGR32;
format = PIXEL_FORMAT_BGRA32;
break;

case 24:
Expand All @@ -363,6 +391,10 @@ UINT32 gdi_get_pixel_format(UINT32 bitsPerPixel)
case 8:
format = PIXEL_FORMAT_RGB8;
break;

default:
format = 0;
break;
}

return format;
Expand Down

0 comments on commit df764f5

Please sign in to comment.