예제 #1
0
파일: gdi.c 프로젝트: AMV007/FreeRDP
static void gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt)
{
	rdpGdi* gdi = context->gdi;

	gdi_BitBlt(gdi->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect,
			dstblt->nWidth, dstblt->nHeight, NULL, 0, 0, gdi_rop3_code(dstblt->bRop));
}
예제 #2
0
파일: gdi.c 프로젝트: AMV007/FreeRDP
static void gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt)
{
	rdpGdi* gdi = context->gdi;

	gdi_BitBlt(gdi->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect,
			scrblt->nWidth, scrblt->nHeight, gdi->primary->hdc,
			scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop));
}
예제 #3
0
파일: gdi.c 프로젝트: lgqiang/FreeRDP
static BOOL gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt)
{
	rdpGdi* gdi = context->gdi;

	if (gdi_BitBlt(gdi->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect,
			dstblt->nWidth, dstblt->nHeight, NULL, 0, 0, gdi_rop3_code(dstblt->bRop)) == 0)
		return FALSE;
	return TRUE;
}
예제 #4
0
파일: graphics.c 프로젝트: felfert/FreeRDP
void gdi_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, int x, int y)
{
	gdiGlyph* gdi_glyph;
	rdpGdi* gdi = context->gdi;

	gdi_glyph = (gdiGlyph*) glyph;

	gdi_BitBlt(gdi->drawing->hdc, x, y, gdi_glyph->bitmap->width,
			gdi_glyph->bitmap->height, gdi_glyph->hdc, 0, 0, GDI_DSPDxax);
}
예제 #5
0
파일: graphics.c 프로젝트: nfedera/FreeRDP
static BOOL gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
{
    gdiBitmap* gdi_bitmap = (gdiBitmap*) bitmap;
    UINT32 width = bitmap->right - bitmap->left + 1;
    UINT32 height = bitmap->bottom - bitmap->top + 1;
    return gdi_BitBlt(context->gdi->primary->hdc,
                      bitmap->left, bitmap->top,
                      width, height, gdi_bitmap->hdc,
                      0, 0, GDI_SRCCOPY, &context->gdi->palette);
}
예제 #6
0
파일: gdi.c 프로젝트: lgqiang/FreeRDP
static BOOL gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt)
{
	rdpGdi* gdi = context->gdi;

	if (gdi_BitBlt(gdi->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect,
			scrblt->nWidth, scrblt->nHeight, gdi->primary->hdc,
			scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop)) == 0)
		return FALSE;
	return TRUE;
}
예제 #7
0
파일: gdi.c 프로젝트: AMV007/FreeRDP
static void gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
{
	gdiBitmap* bitmap;
	rdpGdi* gdi = context->gdi;

	bitmap = (gdiBitmap*) memblt->bitmap;

	gdi_BitBlt(gdi->drawing->hdc, memblt->nLeftRect, memblt->nTopRect,
			memblt->nWidth, memblt->nHeight, bitmap->hdc,
			memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop));
}
예제 #8
0
파일: graphics.c 프로젝트: felfert/FreeRDP
void gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
{
	int width, height;
	gdiBitmap* gdi_bitmap = (gdiBitmap*) bitmap;

	width = bitmap->right - bitmap->left + 1;
	height = bitmap->bottom - bitmap->top + 1;

	gdi_BitBlt(context->gdi->primary->hdc, bitmap->left, bitmap->top,
			width, height, gdi_bitmap->hdc, 0, 0, GDI_SRCCOPY);
}
예제 #9
0
파일: graphics.c 프로젝트: nfedera/FreeRDP
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;
}
예제 #10
0
파일: gdi.c 프로젝트: JunaidLoonat/FreeRDP
static BOOL gdi_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
{
	rdpGdi* gdi;

	if (!context || !dstblt)
		return FALSE;

	gdi = context->gdi;
	return gdi_BitBlt(gdi->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect,
	                  dstblt->nWidth, dstblt->nHeight, NULL, 0, 0,
	                  gdi_rop3_code(dstblt->bRop), &gdi->palette);
}
예제 #11
0
파일: gdi.c 프로젝트: lgqiang/FreeRDP
static BOOL gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
{
	gdiBitmap* bitmap;
	rdpGdi* gdi = context->gdi;

	bitmap = (gdiBitmap*) memblt->bitmap;

	if (gdi_BitBlt(gdi->drawing->hdc, memblt->nLeftRect, memblt->nTopRect,
			memblt->nWidth, memblt->nHeight, bitmap->hdc,
			memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop)) == 0)
		return FALSE;
	return TRUE;
}
예제 #12
0
파일: gdi.c 프로젝트: JunaidLoonat/FreeRDP
static BOOL gdi_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt)
{
	rdpGdi* gdi;

	if (!context || !context->gdi)
		return FALSE;

	gdi = context->gdi;
	return gdi_BitBlt(gdi->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect,
	                  scrblt->nWidth, scrblt->nHeight, gdi->primary->hdc,
	                  scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop),
	                  &gdi->palette);
}
예제 #13
0
파일: gdi.c 프로젝트: JunaidLoonat/FreeRDP
static BOOL gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
{
	gdiBitmap* bitmap;
	rdpGdi* gdi;

	if (!context || !memblt || !context->gdi || !memblt->bitmap)
		return FALSE;

	bitmap = (gdiBitmap*) memblt->bitmap;
	gdi = context->gdi;
	return gdi_BitBlt(gdi->drawing->hdc, memblt->nLeftRect, memblt->nTopRect,
	                  memblt->nWidth, memblt->nHeight, bitmap->hdc,
	                  memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop),
	                  &gdi->palette);
}
예제 #14
0
static BOOL test_line(HGDI_DC hdc, const gdiPalette* hPalette, UINT32 mX,
                      UINT32 mY, UINT32 lX, UINT32 lY, HGDI_BITMAP hBmp,
                      HGDI_BITMAP hOrgBmp, UINT32 cX, UINT32 cY, UINT32 cW, UINT32 cH)
{
	if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS, hPalette))
		return FALSE;

	if ((cX > 0) || (cY > 0) || (cW > 0) || (cH > 0))
		gdi_SetClipRgn(hdc, cX, cY, cW, cH);

	gdi_MoveToEx(hdc, mX, mY, NULL);
	gdi_LineTo(hdc, lX, lY);

	if (!test_assert_bitmaps_equal(hBmp, hOrgBmp, "Case 10", hPalette))
		return FALSE;

	return TRUE;
}
예제 #15
0
int TestGdiLine(int argc, char* argv[])
{
	HGDI_DC hdc;
	HGDI_PEN pen;
	BYTE* data;
	HGDI_BITMAP hBmp;
	HGDI_BITMAP hBmp_LineTo_1;
	HGDI_BITMAP hBmp_LineTo_2;
	HGDI_BITMAP hBmp_LineTo_3;
	HGDI_BITMAP hBmp_LineTo_4;
	HGDI_BITMAP hBmp_LineTo_5;
	HGDI_BITMAP hBmp_LineTo_6;
	HGDI_BITMAP hBmp_LineTo_7;
	HGDI_BITMAP hBmp_LineTo_8;
	HGDI_BITMAP hBmp_LineTo_9;
	HGDI_BITMAP hBmp_LineTo_10;
	HGDI_BITMAP hBmp_LineTo_11;
	HGDI_BITMAP hBmp_LineTo_R2_BLACK;
	HGDI_BITMAP hBmp_LineTo_R2_NOTMERGEPEN;
	HGDI_BITMAP hBmp_LineTo_R2_MASKNOTPEN;
	HGDI_BITMAP hBmp_LineTo_R2_NOTCOPYPEN;
	HGDI_BITMAP hBmp_LineTo_R2_MASKPENNOT;
	HGDI_BITMAP hBmp_LineTo_R2_NOT;
	HGDI_BITMAP hBmp_LineTo_R2_XORPEN;
	HGDI_BITMAP hBmp_LineTo_R2_NOTMASKPEN;
	HGDI_BITMAP hBmp_LineTo_R2_MASKPEN;
	HGDI_BITMAP hBmp_LineTo_R2_NOTXORPEN;
	HGDI_BITMAP hBmp_LineTo_R2_NOP;
	HGDI_BITMAP hBmp_LineTo_R2_MERGENOTPEN;
	HGDI_BITMAP hBmp_LineTo_R2_COPYPEN;
	HGDI_BITMAP hBmp_LineTo_R2_MERGEPENNOT;
	HGDI_BITMAP hBmp_LineTo_R2_MERGEPEN;
	HGDI_BITMAP hBmp_LineTo_R2_WHITE;
	rdpPalette* hPalette;
	HCLRCONV clrconv;
	int bitsPerPixel = 8;
	int bytesPerPixel = 1;

	hdc = gdi_GetDC();
	hdc->bitsPerPixel = bitsPerPixel;
	hdc->bytesPerPixel = bytesPerPixel;
	gdi_SetNullClipRgn(hdc);

	pen = gdi_CreatePen(1, 1, 0);
	gdi_SelectObject(hdc, (HGDIOBJECT) pen);

	hBmp = gdi_CreateCompatibleBitmap(hdc, 16, 16);
	gdi_SelectObject(hdc, (HGDIOBJECT) hBmp);

	hPalette = (rdpPalette*) gdi_GetSystemPalette();

	clrconv = (HCLRCONV) malloc(sizeof(CLRCONV));
	clrconv->alpha = 1;
	clrconv->invert = 0;
	clrconv->palette = hPalette;

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_1, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_1 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_2, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_2 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_3, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_3 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_4, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_4 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_5, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_5 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_5, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_5 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_6, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_6 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_7, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_7 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_8, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_8 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_9, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_9 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_10, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_10 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_11, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_11 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_BLACK, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_BLACK = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOTMERGEPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_NOTMERGEPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MASKNOTPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_MASKNOTPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOTCOPYPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_NOTCOPYPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MASKPENNOT, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_MASKPENNOT = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOT, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_NOT = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_XORPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_XORPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOTMASKPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_NOTMASKPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MASKPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_MASKPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOTXORPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_NOTXORPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOP, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_NOP = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MERGENOTPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_MERGENOTPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_COPYPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_COPYPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MERGEPENNOT, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_MERGEPENNOT = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MERGEPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_MERGEPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_WHITE, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_WHITE = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	/* Test Case 1: (0,0) -> (15, 15) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_LineTo(hdc, 15, 15);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_1, "Case 1") < 0)
		return -1;

	/* Test Case 2: (15,15) -> (0,0) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 15, 15, NULL);
	gdi_LineTo(hdc, 0, 0);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_2, "Case 2") < 0)
		return -1;

	/* Test Case 3: (15,0) -> (0,15) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 15, 0, NULL);
	gdi_LineTo(hdc, 0, 15);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_3, "Case 3") < 0)
		return -1;

	/* Test Case 4: (0,15) -> (15,0) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 0, 15, NULL);
	gdi_LineTo(hdc, 15, 0);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_4, "Case 4") < 0)
		return -1;

	/* Test Case 5: (0,8) -> (15,8) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 0, 8, NULL);
	gdi_LineTo(hdc, 15, 8);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_5, "Case 5") < 0)
		return -1;

	/* Test Case 6: (15,8) -> (0,8) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 15, 8, NULL);
	gdi_LineTo(hdc, 0, 8);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_6, "Case 6") < 0)
		return -1;

	/* Test Case 7: (8,0) -> (8,15) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 8, 0, NULL);
	gdi_LineTo(hdc, 8, 15);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_7, "Case 7") < 0)
		return -1;

	/* Test Case 8: (8,15) -> (8,0) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 8, 15, NULL);
	gdi_LineTo(hdc, 8, 0);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_8, "Case 8") < 0)
		return -1;

	/* Test Case 9: (4,4) -> (12,12) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 4, 4, NULL);
	gdi_LineTo(hdc, 12, 12);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_9, "Case 9") < 0)
		return -1;

	/* Test Case 10: (12,12) -> (4,4) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 12, 12, NULL);
	gdi_LineTo(hdc, 4, 4);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_10, "Case 10") < 0)
		return -1;

	/* Test Case 11: (0,0) -> (+10,+10) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_LineTo(hdc, 16 + 10, 16 + 10);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_11, "Case 11") < 0)
		return -1;

	/* Test Case 12: (0,0) -> (16,16), R2_BLACK */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_BLACK);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_BLACK, "Case 12") < 0)
		return -1;

	/* Test Case 13: (0,0) -> (16,16), R2_NOTMERGEPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_NOTMERGEPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOTMERGEPEN, "Case 13") < 0)
		return -1;

	/* Test Case 14: (0,0) -> (16,16), R2_MASKNOTPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_MASKNOTPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MASKNOTPEN, "Case 14") < 0)
		return -1;

	/* Test Case 15: (0,0) -> (16,16), R2_NOTCOPYPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_NOTCOPYPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOTCOPYPEN, "Case 15") < 0)
		return -1;

	/* Test Case 16: (0,0) -> (16,16), R2_MASKPENNOT */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_MASKPENNOT);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MASKPENNOT, "Case 16") < 0)
		return -1;

	/* Test Case 17: (0,0) -> (16,16), R2_NOT */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_NOT);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOT, "Case 17") < 0)
		return -1;

	/* Test Case 18: (0,0) -> (16,16), R2_XORPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_XORPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_XORPEN, "Case 18") < 0)
		return -1;

	/* Test Case 19: (0,0) -> (16,16), R2_NOTMASKPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_NOTMASKPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOTMASKPEN, "Case 19") < 0)
		return -1;

	/* Test Case 20: (0,0) -> (16,16), R2_MASKPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_MASKPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MASKPEN, "Case 20") < 0)
		return -1;

	/* Test Case 21: (0,0) -> (16,16), R2_NOTXORPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_NOTXORPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOTXORPEN, "Case 21") < 0)
		return -1;

	/* Test Case 22: (0,0) -> (16,16), R2_NOP */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_NOP);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOP, "Case 22") < 0)
		return -1;

	/* Test Case 23: (0,0) -> (16,16), R2_MERGENOTPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_MERGENOTPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MERGENOTPEN, "Case 23") < 0)
		return -1;

	/* Test Case 24: (0,0) -> (16,16), R2_COPYPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_COPYPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_COPYPEN, "Case 24") < 0)
		return -1;

	/* Test Case 25: (0,0) -> (16,16), R2_MERGEPENNOT */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_MERGEPENNOT);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MERGEPENNOT, "Case 25") < 0)
		return -1;

	/* Test Case 26: (0,0) -> (16,16), R2_MERGEPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_MERGEPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MERGEPEN, "Case 26") < 0)
		return -1;

	/* Test Case 27: (0,0) -> (16,16), R2_WHITE */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_WHITE);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_WHITE, "Case 27") < 0)
		return -1;

	return 0;
}
예제 #16
0
int TestGdiLine(int argc, char* argv[])
{
	int rc = -1;
	UINT32 x, i;
	gdiPalette g;
	const UINT32 RawFormat = PIXEL_FORMAT_RGB8;
	const UINT32 colorFormats[] =
	{
		PIXEL_FORMAT_RGB15,
		PIXEL_FORMAT_ARGB15,
		PIXEL_FORMAT_RGB16,
		PIXEL_FORMAT_RGB24,
		PIXEL_FORMAT_ARGB32,
		PIXEL_FORMAT_XRGB32,
		PIXEL_FORMAT_RGBA32,
		PIXEL_FORMAT_RGBX32,
		PIXEL_FORMAT_BGR15,
		PIXEL_FORMAT_ABGR15,
		PIXEL_FORMAT_BGR16,
		PIXEL_FORMAT_BGR24,
		PIXEL_FORMAT_ABGR32,
		PIXEL_FORMAT_XBGR32,
		PIXEL_FORMAT_BGRA32,
		PIXEL_FORMAT_BGRX32
	};
	const UINT32 number_formats = sizeof(colorFormats) / sizeof(colorFormats[0]);

	for (i = 0; i < number_formats; i++)
	{
		HGDI_DC hdc = NULL;
		HGDI_PEN pen = NULL;
		HGDI_BITMAP hBmp = NULL;
		struct ropMap rop_map[] =
		{
			{GDI_R2_BLACK, NULL, line_to_R2_BLACK},
			{GDI_R2_NOTMERGEPEN, NULL, line_to_R2_NOTMERGEPEN},
			{GDI_R2_MASKNOTPEN, NULL, line_to_R2_MASKNOTPEN},
			{GDI_R2_NOTCOPYPEN, NULL, line_to_R2_NOTCOPYPEN},
			{GDI_R2_MASKPENNOT, NULL, line_to_R2_MASKPENNOT},
			{GDI_R2_NOT, NULL, line_to_R2_NOT},
			{GDI_R2_XORPEN, NULL, line_to_R2_XORPEN},
			{GDI_R2_NOTMASKPEN, NULL, line_to_R2_NOTMASKPEN},
			{GDI_R2_MASKPEN, NULL, line_to_R2_MASKPEN},
			{GDI_R2_NOTXORPEN, NULL, line_to_R2_NOTXORPEN},
			{GDI_R2_NOP, NULL, line_to_R2_NOP},
			{GDI_R2_MERGENOTPEN, NULL, line_to_R2_MERGENOTPEN},
			{GDI_R2_COPYPEN, NULL, line_to_R2_COPYPEN},
			{GDI_R2_MERGEPENNOT, NULL, line_to_R2_MERGEPENNOT},
			{GDI_R2_MERGEPEN, NULL, line_to_R2_MERGEPEN},
			{GDI_R2_WHITE, NULL, line_to_R2_WHITE}
		};
		const UINT32 map_size = sizeof(rop_map) / sizeof(rop_map[0]);
		HGDI_BITMAP hBmp_LineTo[LINTETO_NUMBER] = {NULL};
		gdiPalette* hPalette = &g;
		UINT32 penColor;
		const UINT32 format = colorFormats[i];
		g.format = format;

		for (i = 0; i < 256; i++)
			g.palette[i] = GetColor(format, i, i, i, 0xFF);

		rc = -1;

		if (!(hdc = gdi_GetDC()))
		{
			printf("failed to get gdi device context\n");
			goto fail;
		}

		hdc->format = format;
		gdi_SetNullClipRgn(hdc);
		penColor = GetColor(format, 0xFF, 0xFF, 0xFF, 0xFF);

		if (!(pen = gdi_CreatePen(1, 1, penColor, format, hPalette)))
		{
			printf("gdi_CreatePen failed\n");
			goto fail;
		}

		gdi_SelectObject(hdc, (HGDIOBJECT) pen);
		hBmp = gdi_CreateCompatibleBitmap(hdc, 16, 16);
		gdi_SelectObject(hdc, (HGDIOBJECT) hBmp);

		for (x = 0; x < LINTETO_NUMBER; x++)
		{
			hBmp_LineTo[x] = test_convert_to_bitmap(line_to_case[x], RawFormat, 0, 0, 0,
			                                        format, 0, 0, 0, 16, 16, hPalette);

			if (!hBmp_LineTo[x])
				goto fail;
		}

		for (x = 0; x < map_size; x++)
		{
			rop_map[x].bmp = test_convert_to_bitmap(rop_map[x].src, RawFormat, 0, 0, 0,
			                                        format, 0, 0, 0, 16, 16, hPalette);

			if (!rop_map[x].bmp)
				goto fail;
		}

		if (!test_line(hdc, hPalette, 0, 0, 15, 15, hBmp, hBmp_LineTo[0], 0, 0, 16, 16))
			goto fail;

		if (!test_line(hdc, hPalette, 15, 15, 0, 0, hBmp, hBmp_LineTo[1], 0, 0, 16, 16))
			goto fail;

		if (!test_line(hdc, hPalette, 15, 0, 0, 15, hBmp, hBmp_LineTo[2], 0, 0, 16, 16))
			goto fail;

		if (!test_line(hdc, hPalette, 0, 15, 15, 0, hBmp, hBmp_LineTo[3], 0, 0, 16, 16))
			goto fail;

		if (!test_line(hdc, hPalette, 0, 8, 15, 8, hBmp, hBmp_LineTo[4], 0, 0, 16, 16))
			goto fail;

		if (!test_line(hdc, hPalette, 15, 8, 0, 8, hBmp, hBmp_LineTo[5], 0, 0, 16, 16))
			goto fail;

		if (!test_line(hdc, hPalette, 8, 0, 8, 15, hBmp, hBmp_LineTo[6], 0, 0, 16, 16))
			goto fail;

		if (!test_line(hdc, hPalette, 8, 15, 8, 0, hBmp, hBmp_LineTo[7], 0, 0, 16, 16))
			goto fail;

		if (!test_line(hdc, hPalette, 4, 4, 12, 12, hBmp, hBmp_LineTo[8], 0, 0, 16, 16))
			goto fail;

		if (!test_line(hdc, hPalette, 0, 0, 16, 16, hBmp, hBmp_LineTo[9], 5, 5, 8, 8))
			goto fail;

		if (!test_line(hdc, hPalette, 0, 0, 26, 26, hBmp, hBmp_LineTo[10], 0, 0, 16,
		               16))
			goto fail;

		for (x = 0; x < map_size; x++)
		{
			char name[1024];
			_snprintf(name, sizeof(name), "%s [%s]", gdi_rop_to_string(rop_map[x].rop),
			          GetColorFormatName(hdc->format));

			/* Test Case 13: (0,0) -> (16,16), R2_NOTMERGEPEN */
			if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS, hPalette))
			{
				printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
				goto fail;
			}

			gdi_SetClipRgn(hdc, 0, 0, 16, 16);
			gdi_MoveToEx(hdc, 0, 0, NULL);
			gdi_SetROP2(hdc, rop_map[x].rop);
			gdi_LineTo(hdc, 16, 16);

			if (!test_assert_bitmaps_equal(hBmp, rop_map[x].bmp,
			                               name,
			                               hPalette))
				goto fail;
		}

		rc = 0;
	fail:

		for (x = 0; x < LINTETO_NUMBER; x++)
			gdi_DeleteObject((HGDIOBJECT) hBmp_LineTo[x]);

		for (x = 0; x < map_size; x++)
			gdi_DeleteObject((HGDIOBJECT) rop_map[x].bmp);

		gdi_DeleteObject((HGDIOBJECT) pen);
		gdi_DeleteDC(hdc);

		if (rc != 0)
			break;
	}

	return rc;
}
예제 #17
0
int TestGdiEllipse(int argc, char* argv[])
{
	int rc = -1;
	UINT32 i, j;
	const UINT32 RawFormat = PIXEL_FORMAT_RGB8;
	const UINT32 colorFormats[] =
	{
		PIXEL_FORMAT_RGB15,
		PIXEL_FORMAT_ARGB15,
		PIXEL_FORMAT_RGB16,
		PIXEL_FORMAT_RGB24,
		PIXEL_FORMAT_ARGB32,
		PIXEL_FORMAT_XRGB32,
		PIXEL_FORMAT_RGBA32,
		PIXEL_FORMAT_RGBX32,
		PIXEL_FORMAT_BGR15,
		PIXEL_FORMAT_ABGR15,
		PIXEL_FORMAT_BGR16,
		PIXEL_FORMAT_BGR24,
		PIXEL_FORMAT_ABGR32,
		PIXEL_FORMAT_XBGR32,
		PIXEL_FORMAT_BGRA32,
		PIXEL_FORMAT_BGRX32
	};
	const UINT32 number_formats = sizeof(colorFormats) / sizeof(colorFormats[0]);
	gdiPalette g;

	for (i = 0; i < number_formats; i++)
	{
		HGDI_DC hdc = NULL;
		HGDI_PEN pen = NULL;
		HGDI_BITMAP hBmp = NULL;
		HGDI_BITMAP hBmp_Ellipse_1 = NULL;
		HGDI_BITMAP hBmp_Ellipse_2 = NULL;
		HGDI_BITMAP hBmp_Ellipse_3 = NULL;
		const UINT32 format = colorFormats[i];
		gdiPalette* hPalette = &g;
		g.format = format;

		for (j = 0; j < 256; j++)
			g.palette[i] = GetColor(format, j, j, j, 0xFF);

		rc = -1;

		if (!(hdc = gdi_GetDC()))
		{
			printf("failed to get gdi device context\n");
			goto fail;
		}

		hdc->format = format;
		gdi_SetNullClipRgn(hdc);

		if (!(pen = gdi_CreatePen(1, 1, 0, format, hPalette)))
		{
			printf("gdi_CreatePen failed\n");
			goto fail;
		}

		gdi_SelectObject(hdc, (HGDIOBJECT) pen);
		hBmp = gdi_CreateCompatibleBitmap(hdc, 16, 16);
		gdi_SelectObject(hdc, (HGDIOBJECT) hBmp);
		hBmp_Ellipse_1 = test_convert_to_bitmap(ellipse_case_1, RawFormat, 0, 0, 0,
		                                        format, 0, 0, 0, 16, 16, hPalette);

		if (!hBmp_Ellipse_1)
			goto fail;

		hBmp_Ellipse_2 = test_convert_to_bitmap(ellipse_case_2, RawFormat, 0, 0, 0,
		                                        format, 0, 0, 0, 16, 16, hPalette);

		if (!hBmp_Ellipse_2)
			goto fail;

		hBmp_Ellipse_3 = test_convert_to_bitmap(ellipse_case_3, RawFormat, 0, 0, 0,
		                                        format, 0, 0, 0, 16, 16, hPalette);

		if (!hBmp_Ellipse_3)
			goto fail;

		/* Test Case 1: (0,0) -> (16, 16) */
		if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS, hPalette))
		{
			printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
			goto fail;
		}

		if (!gdi_Ellipse(hdc, 0, 0, 15, 15))
			goto fail;

		rc = 0;
	fail:
		gdi_DeleteObject((HGDIOBJECT) hBmp_Ellipse_1);
		gdi_DeleteObject((HGDIOBJECT) hBmp_Ellipse_2);
		gdi_DeleteObject((HGDIOBJECT) hBmp_Ellipse_3);
		gdi_DeleteObject((HGDIOBJECT) hBmp);
		gdi_DeleteObject((HGDIOBJECT) pen);
		gdi_DeleteDC(hdc);

		if (rc != 0)
			break;
	}

	return rc;
}
예제 #18
0
파일: gdi.c 프로젝트: AMV007/FreeRDP
static void gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
{
	BYTE* data;
	rdpBrush* brush;
	UINT32 foreColor;
	UINT32 backColor;
	gdiBitmap* bitmap;
	GDI_COLOR originalColor;
	HGDI_BRUSH originalBrush;
	rdpGdi* gdi = context->gdi;

	brush = &mem3blt->brush;
	bitmap = (gdiBitmap*) mem3blt->bitmap;

	foreColor = freerdp_convert_gdi_order_color(mem3blt->foreColor, gdi->srcBpp, gdi->format, gdi->palette);
	backColor = freerdp_convert_gdi_order_color(mem3blt->backColor, gdi->srcBpp, gdi->format, gdi->palette);

	originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);

	if (brush->style == GDI_BS_SOLID)
	{
		originalBrush = gdi->drawing->hdc->brush;
		gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor);

		gdi_BitBlt(gdi->drawing->hdc, mem3blt->nLeftRect, mem3blt->nTopRect,
				mem3blt->nWidth, mem3blt->nHeight, bitmap->hdc,
				mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop));

		gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
		gdi->drawing->hdc->brush = originalBrush;
	}
	else if (brush->style == GDI_BS_PATTERN)
	{
		HGDI_BITMAP hBmp;
		UINT32 brushFormat;

		if (brush->bpp > 1)
		{
			brushFormat = gdi_get_pixel_format(brush->bpp, FALSE);

			data = (BYTE*) _aligned_malloc(8 * 8 * gdi->bytesPerPixel, 16);

			freerdp_image_copy(data, gdi->format, -1, 0, 0,
					8, 8, brush->data, brushFormat, -1, 0, 0, gdi->palette);
		}
		else
		{
			data = (BYTE*) _aligned_malloc(8 * 8 * gdi->bytesPerPixel, 16);

			freerdp_image_copy_from_monochrome(data, gdi->format, -1, 0, 0, 8, 8,
					brush->data, backColor, foreColor, gdi->palette);
		}

		hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->bitsPerPixel, data);

		originalBrush = gdi->drawing->hdc->brush;
		gdi->drawing->hdc->brush = gdi_CreatePatternBrush(hBmp);

		gdi_BitBlt(gdi->drawing->hdc, mem3blt->nLeftRect, mem3blt->nTopRect,
				mem3blt->nWidth, mem3blt->nHeight, bitmap->hdc,
				mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop));

		gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
		gdi->drawing->hdc->brush = originalBrush;
	}
	else
	{
		WLog_ERR(TAG,  "Mem3Blt unimplemented brush style:%d", brush->style);
	}

	gdi_SetTextColor(gdi->drawing->hdc, originalColor);
}
예제 #19
0
파일: gdi.c 프로젝트: JunaidLoonat/FreeRDP
static BOOL gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
{
	const rdpBrush* brush = &patblt->brush;
	UINT32 foreColor;
	UINT32 backColor;
	UINT32 originalColor;
	HGDI_BRUSH originalBrush, hbrush = NULL;
	rdpGdi* gdi = context->gdi;
	BOOL ret = FALSE;
	const DWORD rop = gdi_rop3_code(patblt->bRop);
	UINT32 nXSrc = 0;
	UINT32 nYSrc = 0;
	BYTE data[8 * 8 * 4];
	HGDI_BITMAP hBmp = NULL;

	if (!gdi_decode_color(gdi, patblt->foreColor, &foreColor, NULL))
		return FALSE;

	if (!gdi_decode_color(gdi, patblt->backColor, &backColor, NULL))
		return FALSE;

	originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
	originalBrush = gdi->drawing->hdc->brush;

	switch (brush->style)
	{
		case GDI_BS_SOLID:
			hbrush = gdi_CreateSolidBrush(foreColor);
			break;

		case GDI_BS_HATCHED:
			{
				const BYTE* hatched;
				hatched = GDI_BS_HATCHED_PATTERNS + (8 * brush->hatch);

				if (!freerdp_image_copy_from_monochrome(data, gdi->drawing->hdc->format, 0, 0,
				                                        0, 8, 8,
				                                        hatched, backColor, foreColor, &gdi->palette))
					goto out_error;

				hBmp = gdi_CreateBitmapEx(8, 8, gdi->drawing->hdc->format, 0, data, NULL);

				if (!hBmp)
					goto out_error;

				hbrush = gdi_CreateHatchBrush(hBmp);
			}
			break;

		case GDI_BS_PATTERN:
			{
				UINT32 brushFormat;

				if (brush->bpp > 1)
				{
					brushFormat = gdi_get_pixel_format(brush->bpp);

					if (!freerdp_image_copy(data, gdi->drawing->hdc->format, 0, 0, 0,
					                        8, 8, brush->data, brushFormat, 0, 0, 0,
					                        &gdi->palette, FREERDP_FLIP_NONE))
						goto out_error;
				}
				else
				{
					if (!freerdp_image_copy_from_monochrome(data, gdi->drawing->hdc->format, 0, 0,
					                                        0, 8, 8,
					                                        brush->data, backColor, foreColor, &gdi->palette))
						goto out_error;
				}

				hBmp = gdi_CreateBitmapEx(8, 8, gdi->drawing->hdc->format, 0, data, NULL);

				if (!hBmp)
					goto out_error;

				hbrush = gdi_CreatePatternBrush(hBmp);
			}
			break;

		default:
			WLog_ERR(TAG,  "unimplemented brush style:%"PRIu32"", brush->style);
			break;
	}

	if (!hbrush)
		gdi_DeleteObject((HGDIOBJECT) hBmp);
	else
	{
		hbrush->nXOrg = brush->x;
		hbrush->nYOrg = brush->y;
		gdi->drawing->hdc->brush = hbrush;
		ret = gdi_BitBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
		                 patblt->nWidth, patblt->nHeight,
		                 gdi->primary->hdc, nXSrc, nYSrc, rop, &gdi->palette);
	}

out_error:
	gdi_DeleteObject((HGDIOBJECT) hbrush);
	gdi->drawing->hdc->brush = originalBrush;
	gdi_SetTextColor(gdi->drawing->hdc, originalColor);
	return ret;
}
예제 #20
0
파일: gdi.c 프로젝트: AMV007/FreeRDP
static void gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* cmd)
{
	int i, j;
	int tx, ty;
	BYTE* pSrcData;
	BYTE* pDstData;
	RFX_MESSAGE* message;
	rdpGdi* gdi = context->gdi;

	DEBUG_GDI("destLeft %d destTop %d destRight %d destBottom %d "
		"bpp %d codecID %d width %d height %d length %d",
		cmd->destLeft, cmd->destTop, cmd->destRight, cmd->destBottom,
		cmd->bpp, cmd->codecID, cmd->width, cmd->height, cmd->bitmapDataLength);

	if (cmd->codecID == RDP_CODEC_ID_REMOTEFX)
	{
		freerdp_client_codecs_prepare(gdi->codecs, FREERDP_CODEC_REMOTEFX);

		message = rfx_process_message(gdi->codecs->rfx, cmd->bitmapData, cmd->bitmapDataLength);

		/* blit each tile */
		for (i = 0; i < message->numTiles; i++)
		{
			tx = message->tiles[i]->x + cmd->destLeft;
			ty = message->tiles[i]->y + cmd->destTop;

			pSrcData = message->tiles[i]->data;
			pDstData = gdi->tile->bitmap->data;

			if (!gdi->invert && (gdi->dstBpp == 32))
			{
				gdi->tile->bitmap->data = pSrcData;
			}
			else
			{
				freerdp_image_copy(pDstData, gdi->format, -1, 0, 0,
						64, 64, pSrcData, PIXEL_FORMAT_XRGB32, -1, 0, 0, gdi->palette);
			}

			for (j = 0; j < message->numRects; j++)
			{
				gdi_SetClipRgn(gdi->primary->hdc,
					cmd->destLeft + message->rects[j].x,
					cmd->destTop + message->rects[j].y,
					message->rects[j].width, message->rects[j].height);

				gdi_BitBlt(gdi->primary->hdc, tx, ty, 64, 64, gdi->tile->hdc, 0, 0, GDI_SRCCOPY);
			}

			gdi->tile->bitmap->data = pDstData;
		}

		gdi_SetNullClipRgn(gdi->primary->hdc);
		rfx_message_free(gdi->codecs->rfx, message);
	}
	else if (cmd->codecID == RDP_CODEC_ID_NSCODEC)
	{
		freerdp_client_codecs_prepare(gdi->codecs, FREERDP_CODEC_NSCODEC);

		nsc_process_message(gdi->codecs->nsc, cmd->bpp, cmd->width, cmd->height, cmd->bitmapData, cmd->bitmapDataLength);

		if (gdi->bitmap_size < (cmd->width * cmd->height * 4))
		{
			gdi->bitmap_size = cmd->width * cmd->height * 4;
			gdi->bitmap_buffer = (BYTE*) _aligned_realloc(gdi->bitmap_buffer, gdi->bitmap_size, 16);

			if (!gdi->bitmap_buffer)
				return;
		}

		pDstData = gdi->bitmap_buffer;
		pSrcData = gdi->codecs->nsc->BitmapData;

		freerdp_image_copy(pDstData, gdi->format, -1, 0, 0,
				cmd->width, cmd->height, pSrcData, PIXEL_FORMAT_XRGB32_VF, -1, 0, 0, gdi->palette);

		gdi->image->bitmap->width = cmd->width;
		gdi->image->bitmap->height = cmd->height;
		gdi->image->bitmap->bitsPerPixel = cmd->bpp;
		gdi->image->bitmap->bytesPerPixel = cmd->bpp / 8;
		gdi->image->bitmap->data = gdi->bitmap_buffer;

		gdi_BitBlt(gdi->primary->hdc, cmd->destLeft, cmd->destTop, cmd->width, cmd->height, gdi->image->hdc, 0, 0, GDI_SRCCOPY);
	} 
	else if (cmd->codecID == RDP_CODEC_ID_NONE)
	{
		if (gdi->bitmap_size < (cmd->width * cmd->height * 4))
		{
			gdi->bitmap_size = cmd->width * cmd->height * 4;
			gdi->bitmap_buffer = (BYTE*) _aligned_realloc(gdi->bitmap_buffer, gdi->bitmap_size, 16);

			if (!gdi->bitmap_buffer)
				return;
		}

		pDstData = gdi->bitmap_buffer;
		pSrcData = cmd->bitmapData;

		freerdp_image_copy(pDstData, gdi->format, -1, 0, 0,
				cmd->width, cmd->height, pSrcData, PIXEL_FORMAT_XRGB32_VF, -1, 0, 0, gdi->palette);

		gdi->image->bitmap->width = cmd->width;
		gdi->image->bitmap->height = cmd->height;
		gdi->image->bitmap->bitsPerPixel = cmd->bpp;
		gdi->image->bitmap->bytesPerPixel = cmd->bpp / 8;
		gdi->image->bitmap->data = gdi->bitmap_buffer;

		gdi_BitBlt(gdi->primary->hdc, cmd->destLeft, cmd->destTop, cmd->width, cmd->height, gdi->image->hdc, 0, 0, GDI_SRCCOPY);
	}
	else
	{
		WLog_ERR(TAG, "Unsupported codecID %d", cmd->codecID);
	}
}
예제 #21
0
파일: gdi.c 프로젝트: JunaidLoonat/FreeRDP
static BOOL gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
{
	HGDI_BRUSH originalBrush;
	rdpGdi* gdi = context->gdi;
	BOOL ret = TRUE;
	const rdpBrush* brush = &mem3blt->brush;
	gdiBitmap* bitmap = (gdiBitmap*) mem3blt->bitmap;
	UINT32 foreColor;
	UINT32 backColor;
	UINT32 originalColor;

	if (!gdi_decode_color(gdi, mem3blt->foreColor, &foreColor, NULL))
		return FALSE;

	if (!gdi_decode_color(gdi, mem3blt->backColor, &backColor, NULL))
		return FALSE;

	originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);

	switch (brush->style)
	{
		case GDI_BS_SOLID:
			originalBrush = gdi->drawing->hdc->brush;
			gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor);

			if (!gdi->drawing->hdc->brush)
			{
				ret = FALSE;
				goto out_fail;
			}

			ret = gdi_BitBlt(gdi->drawing->hdc, mem3blt->nLeftRect, mem3blt->nTopRect,
			                 mem3blt->nWidth, mem3blt->nHeight, bitmap->hdc,
			                 mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop),
			                 &gdi->palette);
			gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
			gdi->drawing->hdc->brush = originalBrush;
			break;

		case GDI_BS_PATTERN:
			{
				HGDI_BITMAP hBmp;
				UINT32 brushFormat;
				BYTE* data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(
				        gdi->drawing->hdc->format),
				                                     16);

				if (!data)
				{
					ret = FALSE;
					goto out_fail;
				}

				if (brush->bpp > 1)
				{
					brushFormat = gdi_get_pixel_format(brush->bpp);

					if (!freerdp_image_copy(data, gdi->drawing->hdc->format, 0, 0, 0,
					                        8, 8, brush->data, brushFormat,
					                        0, 0, 0, &gdi->palette, FREERDP_FLIP_NONE))
					{
						ret = FALSE;
						_aligned_free(data);
						goto out_fail;
					}
				}
				else
				{
					if (!freerdp_image_copy_from_monochrome(data, gdi->drawing->hdc->format, 0, 0,
					                                        0, 8, 8,
					                                        brush->data, backColor, foreColor,
					                                        &gdi->palette))
					{
						ret = FALSE;
						_aligned_free(data);
						goto out_fail;
					}
				}

				hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);

				if (!hBmp)
				{
					ret = FALSE;
					_aligned_free(data);
					goto out_fail;
				}

				originalBrush = gdi->drawing->hdc->brush;
				gdi->drawing->hdc->brush = gdi_CreatePatternBrush(hBmp);

				if (!gdi->drawing->hdc->brush)
				{
					gdi_DeleteObject((HGDIOBJECT) hBmp);
					goto out_fail;
				}

				gdi->drawing->hdc->brush->nXOrg = brush->x;
				gdi->drawing->hdc->brush->nYOrg = brush->y;
				ret = gdi_BitBlt(gdi->drawing->hdc, mem3blt->nLeftRect, mem3blt->nTopRect,
				                 mem3blt->nWidth, mem3blt->nHeight, bitmap->hdc,
				                 mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop),
				                 &gdi->palette);
				gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
				gdi->drawing->hdc->brush = originalBrush;
			}
			break;

		default:
			WLog_ERR(TAG,  "Mem3Blt unimplemented brush style:%"PRIu32"", brush->style);
			break;
	}

out_fail:
	gdi_SetTextColor(gdi->drawing->hdc, originalColor);
	return ret;
}