コード例 #1
0
ファイル: TestGdiCreate.c プロジェクト: C4rt/FreeRDP
int test_gdi_SetPixel(void)
{
	HGDI_DC hdc;
	int width = 128;
	int height = 64;
	HGDI_BITMAP hBitmap;

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

	hdc->bytesPerPixel = 4;
	hdc->bitsPerPixel = 32;

	hBitmap = gdi_CreateCompatibleBitmap(hdc, width, height);
	gdi_SelectObject(hdc, (HGDIOBJECT) hBitmap);

	gdi_SetPixel(hdc, 32, 64, 0xAABBCCDD);

	if (gdi_GetPixel(hdc, 32, 64) != 0xAABBCCDD)
		return -1;

	gdi_SetPixel(hdc, width - 1, height - 1, 0xAABBCCDD);

	if (gdi_GetPixel(hdc, width - 1, height - 1) != 0xAABBCCDD)
		return -1;

	gdi_DeleteObject((HGDIOBJECT) hBitmap);

	return 0;
}
コード例 #2
0
ファイル: shape.c プロジェクト: 99455125/FreeRDP
static void Ellipse_Bresenham(HGDI_DC hdc, int x1, int y1, int x2, int y2)
{
	INT32 e, e2;
	INT32 dx, dy;
	INT32 a, b, c;
	a = (x1 < x2) ? x2 - x1 : x1 - x2;
	b = (y1 < y2) ? y2 - y1 : y1 - y2;
	c = b & 1;
	dx = 4 * (1 - a) * b * b;
	dy = 4 * (c + 1) * a * a;
	e = dx + dy + c * a * a;

	if (x1 > x2)
	{
		x1 = x2;
		x2 += a;
	}

	if (y1 > y2)
		y1 = y2;

	y1 += (b + 1) / 2;
	y2 = y1 - c;
	a *= 8 * a;
	c = 8 * b * b;

	do
	{
		gdi_SetPixel(hdc, x2, y1, 0);
		gdi_SetPixel(hdc, x1, y1, 0);
		gdi_SetPixel(hdc, x1, y2, 0);
		gdi_SetPixel(hdc, x2, y2, 0);
		e2 = 2 * e;

		if (e2 >= dx)
		{
			x1++;
			x2--;
			e += dx += c;
		}

		if (e2 <= dy)
		{
			y1++;
			y2--;
			e += dy += a;
		}
	}
	while (x1 <= x2);

	while (y1 - y2 < b)
	{
		gdi_SetPixel(hdc, x1 - 1, ++y1, 0);
		gdi_SetPixel(hdc, x1 - 1, --y2, 0);
	}
}