mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[freerdp,codec] add freerdp_image_fill_ex
This commit is contained in:
@@ -432,7 +432,7 @@ typedef struct gdi_palette gdiPalette;
|
||||
UINT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
|
||||
UINT32 nSrcWidth, UINT32 nSrcHeight);
|
||||
|
||||
/***
|
||||
/** @brief fill an area with the color provided.
|
||||
*
|
||||
* @param pDstData destination buffer
|
||||
* @param DstFormat destination buffer format
|
||||
@@ -450,6 +450,31 @@ typedef struct gdi_palette gdiPalette;
|
||||
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth,
|
||||
UINT32 nHeight, UINT32 color);
|
||||
|
||||
#define FREERDP_IMAGE_FILL_IGNORE_ALPHA 1 /** @since version 3.13.0 */
|
||||
|
||||
/** @brief fill an area with the color provided. If flag \b FREERDP_IMAGE_FILL_IGNORE_ALPHA is
|
||||
* set the destination alpha value will be kept.
|
||||
*
|
||||
* @param pDstData destination buffer
|
||||
* @param DstFormat destination buffer format
|
||||
* @param nDstStep destination buffer stride (line in bytes) 0 for default
|
||||
* @param nXDst destination buffer offset x
|
||||
* @param nYDst destination buffer offset y
|
||||
* @param nWidth width to copy in pixels
|
||||
* @param nHeight height to copy in pixels
|
||||
* @param color Pixel color in DstFormat (internal representation format,
|
||||
* use FreeRDPGetColor to create)
|
||||
* @param flags \b FREERDP_IMAGE_FILL_* flags
|
||||
*
|
||||
* @return TRUE if success, FALSE otherwise
|
||||
*
|
||||
* @since version 3.13.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_image_fill_ex(BYTE* WINPR_RESTRICT pDstData, DWORD DstFormat,
|
||||
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
|
||||
UINT32 nWidth, UINT32 nHeight, UINT32 color,
|
||||
UINT32 flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1127,6 +1127,37 @@ BOOL freerdp_image_fill(BYTE* WINPR_RESTRICT pDstData, DWORD DstFormat, UINT32 n
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL freerdp_image_fill_ex(BYTE* pDstData, DWORD DstFormat, UINT32 nDstStep, UINT32 nXDst,
|
||||
UINT32 nYDst, UINT32 nWidth, UINT32 nHeight, UINT32 color, UINT32 flags)
|
||||
{
|
||||
if (FreeRDPColorHasAlpha(DstFormat) && ((flags & FREERDP_IMAGE_FILL_IGNORE_ALPHA) != 0))
|
||||
{
|
||||
const UINT32 bpp = FreeRDPGetBytesPerPixel(DstFormat);
|
||||
BYTE r = 0;
|
||||
BYTE g = 0;
|
||||
BYTE b = 0;
|
||||
FreeRDPSplitColor(color, DstFormat, &r, &g, &b, NULL, NULL);
|
||||
|
||||
for (size_t y = 0; y < nHeight; y++)
|
||||
{
|
||||
BYTE* WINPR_RESTRICT line = &pDstData[(y + nYDst) * nDstStep];
|
||||
|
||||
for (size_t x = 0; x < nWidth; x++)
|
||||
{
|
||||
BYTE* WINPR_RESTRICT dst = &line[x * bpp];
|
||||
const UINT32 dcolor = FreeRDPReadColor_int(dst, DstFormat);
|
||||
BYTE a = 0;
|
||||
FreeRDPSplitColor(dcolor, DstFormat, NULL, NULL, NULL, &a, NULL);
|
||||
const UINT32 scolor = FreeRDPGetColor(DstFormat, r, g, b, a);
|
||||
if (!FreeRDPWriteColor_int(dst, DstFormat, scolor))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return freerdp_image_fill(pDstData, DstFormat, nDstStep, nXDst, nYDst, nWidth, nHeight, color);
|
||||
}
|
||||
|
||||
#if defined(WITH_SWSCALE)
|
||||
static int av_format_for_buffer(UINT32 format)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user