FreeRDP
libfreerdp/gdi/gdi.h
1 
20 #ifndef FREERDP_LIB_GDI_CORE_H
21 #define FREERDP_LIB_GDI_CORE_H
22 
23 #include "graphics.h"
24 #include "brush.h"
25 
26 #include <freerdp/api.h>
27 
28 FREERDP_LOCAL BOOL gdi_bitmap_update(rdpContext* context, const BITMAP_UPDATE* bitmapUpdate);
29 
30 FREERDP_LOCAL gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height, int bpp, BYTE* data);
31 FREERDP_LOCAL void gdi_bitmap_free_ex(gdiBitmap* gdi_bmp);
32 
33 static INLINE BYTE* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, INT32 x, INT32 y)
34 {
35  BYTE* p = NULL;
36  HGDI_BITMAP hBmp = (HGDI_BITMAP)hdcBmp->selectedObject;
37 
38  if ((x >= 0) && (y >= 0) && (x < hBmp->width) && (y < hBmp->height))
39  {
40  p = hBmp->data + (y * hBmp->scanline) + (x * FreeRDPGetBytesPerPixel(hdcBmp->format));
41  return p;
42  }
43  else
44  {
45  WLog_ERR(FREERDP_TAG("gdi"),
46  "gdi_get_bitmap_pointer: requesting invalid pointer: (%" PRIu32 ",%" PRIu32
47  ") in %" PRIu32 "x%" PRIu32 "",
48  x, y, hBmp->width, hBmp->height);
49  return 0;
50  }
51 }
52 
60 static INLINE BYTE* gdi_get_brush_pointer(HGDI_DC hdcBrush, UINT32 x, UINT32 y)
61 {
62  BYTE* p = NULL;
63  UINT32 brushStyle = gdi_GetBrushStyle(hdcBrush);
64 
65  switch (brushStyle)
66  {
67  case GDI_BS_PATTERN:
68  case GDI_BS_HATCHED:
69  {
70  HGDI_BITMAP hBmpBrush = hdcBrush->brush->pattern;
71  /* According to msdn{dd183396}, the system always positions a brush bitmap
72  * at the brush origin and copy across the client area.
73  * Calculate the offset of the mapped pixel in the brush bitmap according to
74  * brush origin and dest coordinates */
75  x = (x + hBmpBrush->width - (hdcBrush->brush->nXOrg % hBmpBrush->width)) %
76  hBmpBrush->width;
77  y = (y + hBmpBrush->height - (hdcBrush->brush->nYOrg % hBmpBrush->height)) %
78  hBmpBrush->height;
79  p = hBmpBrush->data + (y * hBmpBrush->scanline) +
80  (x * FreeRDPGetBytesPerPixel(hBmpBrush->format));
81  return p;
82  }
83  break;
84 
85  default:
86  break;
87  }
88 
89  p = (BYTE*)&(hdcBrush->textColor);
90  return p;
91 }
92 
93 #endif /* FREERDP_LIB_GDI_CORE_H */