Fixed various issues with freerdp_bitmap_compress and interleaved_compress

This commit is contained in:
Armin Novak 2018-11-08 17:21:28 +01:00
parent c0c1d064be
commit 9e2c203771
3 changed files with 1113 additions and 1008 deletions

View File

@ -32,8 +32,8 @@
extern "C" {
#endif
FREERDP_API int freerdp_bitmap_compress(const char* in_data, int width, int height,
wStream* s, int bpp, int byte_limit, int start_line, wStream* temp_s, int e);
FREERDP_API SSIZE_T freerdp_bitmap_compress(const void* in_data, UINT32 width, UINT32 height,
wStream* s, UINT32 bpp, UINT32 byte_limit, UINT32 start_line, wStream* temp_s, UINT32 e);
#ifdef __cplusplus
}

File diff suppressed because it is too large Load Diff

View File

@ -381,11 +381,17 @@ BOOL interleaved_compress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
UINT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
const gdiPalette* palette, UINT32 bpp)
{
int status;
BOOL status;
wStream* s;
UINT32 DstFormat = 0;
const size_t maxSize = 64 * 64 * 4;
if (!interleaved || !pDstData || !pSrcData)
return FALSE;
if ((nWidth == 0) || (nHeight == 0))
return FALSE;
if (nWidth % 4)
{
WLog_ERR(TAG, "interleaved_compress: width is not a multiple of 4");
@ -400,31 +406,43 @@ BOOL interleaved_compress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
return FALSE;
}
if (bpp == 24)
DstFormat = PIXEL_FORMAT_BGRX32;
else if (bpp == 16)
DstFormat = PIXEL_FORMAT_RGB16;
else if (bpp == 15)
DstFormat = PIXEL_FORMAT_RGB15;
else if (bpp == 8)
DstFormat = PIXEL_FORMAT_RGB8;
switch (bpp)
{
case 24:
DstFormat = PIXEL_FORMAT_BGRX32;
break;
if (!DstFormat)
return FALSE;
case 16:
DstFormat = PIXEL_FORMAT_RGB16;
break;
case 15:
DstFormat = PIXEL_FORMAT_RGB15;
break;
default:
return FALSE;
}
if (!freerdp_image_copy(interleaved->TempBuffer, DstFormat, 0, 0, 0, nWidth,
nHeight,
pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc, palette, FREERDP_FLIP_NONE))
nHeight, pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc,
palette, FREERDP_FLIP_NONE))
return FALSE;
s = Stream_New(pDstData, maxSize);
s = Stream_New(pDstData, *pDstSize);
if (!s)
return FALSE;
status = freerdp_bitmap_compress((char*) interleaved->TempBuffer, nWidth,
nHeight,
s, bpp, maxSize, nHeight - 1, interleaved->bts, 0);
Stream_SetPosition(interleaved->bts, 0);
if (freerdp_bitmap_compress(interleaved->TempBuffer, nWidth, nHeight,
s, bpp, maxSize, nHeight - 1,
interleaved->bts, 0) < 0)
status = FALSE;
else
status = TRUE;
Stream_SealLength(s);
*pDstSize = (UINT32) Stream_Length(s);
Stream_Free(s, FALSE);