20#ifndef FREERDP_LIB_GDI_CORE_H
21#define FREERDP_LIB_GDI_CORE_H
23#include <winpr/cast.h>
28#include <freerdp/api.h>
31FREERDP_LOCAL BOOL gdi_bitmap_update(rdpContext* context,
const BITMAP_UPDATE* bitmapUpdate);
33FREERDP_LOCAL
void gdi_bitmap_free_ex(gdiBitmap* bitmap);
35WINPR_ATTR_MALLOC(gdi_bitmap_free_ex, 1)
37FREERDP_LOCAL gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi,
int width,
int height,
int bpp, BYTE* data);
40static inline BYTE* gdi_get_bitmap_pointer(
HGDI_DC hdcBmp, INT32 x, INT32 y)
44 if ((x >= 0) && (y >= 0) && (x < hBmp->width) && (y < hBmp->height))
46 BYTE* p = hBmp->data + (WINPR_ASSERTING_INT_CAST(
size_t, y) * hBmp->scanline) +
47 (WINPR_ASSERTING_INT_CAST(
size_t, x) * FreeRDPGetBytesPerPixel(hdcBmp->format));
52 WLog_ERR(FREERDP_TAG(
"gdi"),
53 "gdi_get_bitmap_pointer: requesting invalid pointer: (%" PRId32
",%" PRId32
54 ") in %" PRId32
"x%" PRId32
"",
55 x, y, hBmp->width, hBmp->height);
68static inline BYTE* gdi_get_brush_pointer(
HGDI_DC hdcBrush, UINT32 x, UINT32 y)
71 UINT32 brushStyle = gdi_GetBrushStyle(hdcBrush);
83 const UINT32 w = WINPR_ASSERTING_INT_CAST(UINT32, hBmpBrush->width);
84 const UINT32 h = WINPR_ASSERTING_INT_CAST(UINT32, hBmpBrush->height);
88 x = (x + w - (WINPR_ASSERTING_INT_CAST(UINT32, hdcBrush->brush->nXOrg) % w)) % w;
89 y = (y + h - (WINPR_ASSERTING_INT_CAST(UINT32, hdcBrush->brush->nYOrg) % h)) % h;
90 p = hBmpBrush->data + (1ULL * y * hBmpBrush->scanline) +
91 (1ULL * x * FreeRDPGetBytesPerPixel(hBmpBrush->format));
99 p = (BYTE*)&(hdcBrush->textColor);