static BOOL gdi_multi_opaque_rect(rdpContext* context, const MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect) { UINT32 i; GDI_RECT rect; HGDI_BRUSH hBrush; UINT32 brush_color; rdpGdi* gdi = context->gdi; BOOL ret = TRUE; if (!gdi_decode_color(gdi, multi_opaque_rect->color, &brush_color, NULL)) return FALSE; hBrush = gdi_CreateSolidBrush(brush_color); if (!hBrush) return FALSE; for (i = 0; i < multi_opaque_rect->numRectangles; i++) { const DELTA_RECT* rectangle = &multi_opaque_rect->rectangles[i]; gdi_CRgnToRect(rectangle->left, rectangle->top, rectangle->width, rectangle->height, &rect); ret = gdi_FillRect(gdi->drawing->hdc, &rect, hBrush); if (!ret) break; } gdi_DeleteObject((HGDIOBJECT) hBrush); return ret; }
static BOOL gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect) { int i; GDI_RECT rect; HGDI_BRUSH hBrush; UINT32 brush_color; DELTA_RECT* rectangle; rdpGdi* gdi = context->gdi; BOOL ret = TRUE; for (i = 1; i < (int) multi_opaque_rect->numRectangles + 1; i++) { rectangle = &multi_opaque_rect->rectangles[i]; gdi_CRgnToRect(rectangle->left, rectangle->top, rectangle->width, rectangle->height, &rect); brush_color = freerdp_convert_gdi_order_color(multi_opaque_rect->color, gdi->srcBpp, gdi->format, gdi->palette); hBrush = gdi_CreateSolidBrush(brush_color); if (!hBrush) { ret = FALSE; break; } gdi_FillRect(gdi->drawing->hdc, &rect, hBrush); gdi_DeleteObject((HGDIOBJECT) hBrush); } return ret; }
static BOOL gdi_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, UINT32 x, UINT32 y, UINT32 w, UINT32 h, UINT32 sx, UINT32 sy, BOOL fOpRedundant) { gdiGlyph* gdi_glyph; rdpGdi* gdi; HGDI_BRUSH brush; BOOL rc = FALSE; if (!context || !glyph) return FALSE; gdi = context->gdi; gdi_glyph = (gdiGlyph*) glyph; if (!fOpRedundant && 0) { GDI_RECT rect = { 0 }; if (x > 0) rect.left = x; if (y > 0) rect.top = y; if (x + w > 0) rect.right = x + w - 1; if (y + h > 0) rect.bottom = y + h - 1; if ((rect.left < rect.right) && (rect.top < rect.bottom)) { brush = gdi_CreateSolidBrush(gdi->drawing->hdc->bkColor); if (!brush) return FALSE; gdi_FillRect(gdi->drawing->hdc, &rect, brush); gdi_DeleteObject((HGDIOBJECT)brush); } } brush = gdi_CreateSolidBrush(gdi->drawing->hdc->textColor); if (!brush) return FALSE; gdi_SelectObject(gdi->drawing->hdc, (HGDIOBJECT)brush); rc = gdi_BitBlt(gdi->drawing->hdc, x, y, w, h, gdi_glyph->hdc, sx, sy, GDI_GLYPH_ORDER, &context->gdi->palette); gdi_DeleteObject((HGDIOBJECT)brush); return rc; }
static BOOL gdi_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y, UINT32 width, UINT32 height, UINT32 bgcolor, UINT32 fgcolor, BOOL fOpRedundant) { rdpGdi* gdi; if (!context || !context->gdi) return FALSE; gdi = context->gdi; if (!gdi->drawing || !gdi->drawing->hdc) return FALSE; if (!gdi_decode_color(gdi, bgcolor, &bgcolor, NULL)) return FALSE; if (!gdi_decode_color(gdi, fgcolor, &fgcolor, NULL)) return FALSE; gdi_SetTextColor(gdi->drawing->hdc, bgcolor); gdi_SetBkColor(gdi->drawing->hdc, fgcolor); if (1) { GDI_RECT rect = { 0 }; HGDI_BRUSH brush = gdi_CreateSolidBrush(fgcolor); if (!brush) return FALSE; if (x > 0) rect.left = x; if (y > 0) rect.top = y; rect.right = x + width - 1; rect.bottom = y + height - 1; if ((x + width > rect.left) && (y + height > rect.top)) gdi_FillRect(gdi->drawing->hdc, &rect, brush); gdi_DeleteObject((HGDIOBJECT)brush); } return gdi_SetClipRgn(gdi->drawing->hdc, x, y, width, height); }
static void gdi_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect) { GDI_RECT rect; HGDI_BRUSH hBrush; UINT32 brush_color; rdpGdi* gdi = context->gdi; gdi_CRgnToRect(opaque_rect->nLeftRect, opaque_rect->nTopRect, opaque_rect->nWidth, opaque_rect->nHeight, &rect); brush_color = freerdp_convert_gdi_order_color(opaque_rect->color, gdi->srcBpp, gdi->format, gdi->palette); hBrush = gdi_CreateSolidBrush(brush_color); gdi_FillRect(gdi->drawing->hdc, &rect, hBrush); gdi_DeleteObject((HGDIOBJECT) hBrush); }
void gdi_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height, uint32 bgcolor, uint32 fgcolor) { GDI_RECT rect; HGDI_BRUSH brush; rdpGdi* gdi = context->gdi; bgcolor = freerdp_color_convert_var_bgr(bgcolor, gdi->srcBpp, 32, gdi->clrconv); fgcolor = freerdp_color_convert_var_bgr(fgcolor, gdi->srcBpp, 32, gdi->clrconv); gdi_CRgnToRect(x, y, width, height, &rect); brush = gdi_CreateSolidBrush(fgcolor); gdi_FillRect(gdi->drawing->hdc, &rect, brush); gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor); }
void gdi_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height, UINT32 bgcolor, UINT32 fgcolor, BOOL fOpRedundant) { GDI_RECT rect; HGDI_BRUSH brush; rdpGdi* gdi = context->gdi; /* TODO: handle fOpRedundant! See xf_Glyph_BeginDraw() */ bgcolor = freerdp_convert_gdi_order_color(bgcolor, gdi->srcBpp, gdi->format, gdi->palette); fgcolor = freerdp_convert_gdi_order_color(fgcolor, gdi->srcBpp, gdi->format, gdi->palette); gdi_CRgnToRect(x, y, width, height, &rect); brush = gdi_CreateSolidBrush(fgcolor); gdi_FillRect(gdi->drawing->hdc, &rect, brush); gdi_DeleteObject((HGDIOBJECT) brush); gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor); }
void gdi_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height, UINT32 bgcolor, UINT32 fgcolor) { GDI_RECT rect; HGDI_BRUSH brush; rdpGdi* gdi = context->gdi; bgcolor = freerdp_color_convert_drawing_order_color_to_gdi_color( bgcolor, gdi->srcBpp, gdi->clrconv); fgcolor = freerdp_color_convert_drawing_order_color_to_gdi_color( fgcolor, gdi->srcBpp, gdi->clrconv); gdi_CRgnToRect(x, y, width, height, &rect); brush = gdi_CreateSolidBrush(fgcolor); gdi_FillRect(gdi->drawing->hdc, &rect, brush); gdi_DeleteObject((HGDIOBJECT) brush); gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor); }
static BOOL gdi_opaque_rect(rdpContext* context, const OPAQUE_RECT_ORDER* opaque_rect) { GDI_RECT rect; HGDI_BRUSH hBrush; UINT32 brush_color; rdpGdi* gdi = context->gdi; BOOL ret; gdi_CRgnToRect(opaque_rect->nLeftRect, opaque_rect->nTopRect, opaque_rect->nWidth, opaque_rect->nHeight, &rect); if (!gdi_decode_color(gdi, opaque_rect->color, &brush_color, NULL)) return FALSE; if (!(hBrush = gdi_CreateSolidBrush(brush_color))) return FALSE; ret = gdi_FillRect(gdi->drawing->hdc, &rect, hBrush); gdi_DeleteObject((HGDIOBJECT) hBrush); return ret; }
int test_gdi_FillRect(void) { int rc = -1; HGDI_DC hdc = NULL; HGDI_RECT hRect = NULL; HGDI_BRUSH hBrush = NULL; HGDI_BITMAP hBitmap = NULL; UINT32 color; UINT32 pixel; UINT32 rawPixel; UINT32 x, y; UINT32 badPixels; UINT32 goodPixels; UINT32 width = 200; UINT32 height = 300; UINT32 left = 20; UINT32 top = 40; UINT32 right = 60; UINT32 bottom = 80; if (!(hdc = gdi_GetDC())) { printf("failed to get gdi device context\n"); goto fail; } hdc->format = PIXEL_FORMAT_XRGB32; if (!(hRect = gdi_CreateRect(left, top, right, bottom))) { printf("gdi_CreateRect failed\n"); goto fail; } hBitmap = gdi_CreateCompatibleBitmap(hdc, width, height); ZeroMemory(hBitmap->data, width * height * GetBytesPerPixel(hdc->format)); gdi_SelectObject(hdc, (HGDIOBJECT) hBitmap); color = FreeRDPGetColor(PIXEL_FORMAT_ARGB32, 0xAA, 0xBB, 0xCC, 0xFF); hBrush = gdi_CreateSolidBrush(color); gdi_FillRect(hdc, hRect, hBrush); badPixels = 0; goodPixels = 0; for (x = 0; x < width; x++) { for (y = 0; y < height; y++) { rawPixel = gdi_GetPixel(hdc, x, y); pixel = FreeRDPConvertColor(rawPixel, hdc->format, PIXEL_FORMAT_ARGB32, NULL); if (gdi_PtInRect(hRect, x, y)) { if (pixel == color) { goodPixels++; } else { printf("actual:%08"PRIX32" expected:%08"PRIX32"\n", gdi_GetPixel(hdc, x, y), color); badPixels++; } } else { if (pixel == color) { badPixels++; } else { goodPixels++; } } } } if (goodPixels != width * height) goto fail; if (badPixels != 0) goto fail; rc = 0; fail: gdi_DeleteObject((HGDIOBJECT) hBrush); gdi_DeleteObject((HGDIOBJECT) hBitmap); gdi_DeleteObject((HGDIOBJECT)hRect); gdi_DeleteDC(hdc); return rc; }