libfreerdp-rfx: support encoding 16-bit pixel format.

This commit is contained in:
Vic Lee 2011-09-08 06:53:07 +08:00
parent ac8f60f1e9
commit 7836ceb091
3 changed files with 25 additions and 1 deletions

View File

@ -40,7 +40,9 @@ enum _RFX_PIXEL_FORMAT
RFX_PIXEL_FORMAT_BGRA,
RFX_PIXEL_FORMAT_RGBA,
RFX_PIXEL_FORMAT_BGR,
RFX_PIXEL_FORMAT_RGB
RFX_PIXEL_FORMAT_RGB,
RFX_PIXEL_FORMAT_BGR565_LE,
RFX_PIXEL_FORMAT_RGB565_LE
};
typedef enum _RFX_PIXEL_FORMAT RFX_PIXEL_FORMAT;

View File

@ -189,6 +189,10 @@ void rfx_context_set_pixel_format(RFX_CONTEXT* context, RFX_PIXEL_FORMAT pixel_f
case RFX_PIXEL_FORMAT_RGB:
context->bytes_per_pixel = 3;
break;
case RFX_PIXEL_FORMAT_BGR565_LE:
case RFX_PIXEL_FORMAT_RGB565_LE:
context->bytes_per_pixel = 2;
break;
default:
context->bytes_per_pixel = 0;
break;

View File

@ -82,6 +82,24 @@ static void rfx_encode_format_rgb(const uint8* rgb_data, int width, int height,
*b_buf++ = (sint16) (*src++);
}
break;
case RFX_PIXEL_FORMAT_BGR565_LE:
for (x = 0; x < width; x++)
{
*b_buf++ = (sint16) (((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5));
*g_buf++ = (sint16) ((((*(src + 1)) & 0x07) << 5) | (((*src) & 0xE0) >> 3));
*r_buf++ = (sint16) ((((*src) & 0x1F) << 3) | (((*src) >> 2) & 0x07));
src += 2;
}
break;
case RFX_PIXEL_FORMAT_RGB565_LE:
for (x = 0; x < width; x++)
{
*r_buf++ = (sint16) (((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5));
*g_buf++ = (sint16) ((((*(src + 1)) & 0x07) << 5) | (((*src) & 0xE0) >> 3));
*b_buf++ = (sint16) ((((*src) & 0x1F) << 3) | (((*src) >> 2) & 0x07));
src += 2;
}
break;
default:
break;
}