From c6b9e658f94d53c5356639c754999e11d2a2e42a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Fri, 1 Apr 2011 17:32:35 -0400 Subject: Added two Polygon() test cases --- GdiTest/FreeRDPGDI.cs | 5 +++ GdiTest/GDI.cs | 1 + GdiTest/PolygonDrawingArea.cs | 80 +++++++++++++++++++++++++++++++++++++++++++ GdiTest/Win32GDI.cs | 8 +++++ 4 files changed, 94 insertions(+) diff --git a/GdiTest/FreeRDPGDI.cs b/GdiTest/FreeRDPGDI.cs index 8e8c82f..fff0a49 100644 --- a/GdiTest/FreeRDPGDI.cs +++ b/GdiTest/FreeRDPGDI.cs @@ -127,6 +127,11 @@ namespace GdiTest return false; } + public override bool Polygon(IntPtr hdc, POINT [] lpPoints, int nCount) + { + return false; + } + public override int BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, System.Int32 dwRop) { diff --git a/GdiTest/GDI.cs b/GdiTest/GDI.cs index fc99058..df17f6e 100644 --- a/GdiTest/GDI.cs +++ b/GdiTest/GDI.cs @@ -66,6 +66,7 @@ namespace GdiTest public abstract IntPtr CreatePatternBrush(IntPtr hbmp); public abstract IntPtr CreateBitmap(int nWidth, int nHeight, uint cPlanes, uint cBitsPerPel, IntPtr lpvBits); public abstract bool Ellipse(IntPtr hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect); + public abstract bool Polygon(IntPtr hdc, POINT [] lpPoints, int nCount); public abstract int BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, System.Int32 dwRop); } diff --git a/GdiTest/PolygonDrawingArea.cs b/GdiTest/PolygonDrawingArea.cs index 047fa1f..570e6b8 100644 --- a/GdiTest/PolygonDrawingArea.cs +++ b/GdiTest/PolygonDrawingArea.cs @@ -1,4 +1,8 @@ +using Gtk; +using Cairo; using System; +using System.Drawing; + namespace GdiTest { public class PolygonDrawingArea : TestDrawingArea @@ -10,6 +14,82 @@ namespace GdiTest dumpText = ""; } + protected override bool OnExposeEvent (Gdk.EventExpose args) + { + using (Context cg = Gdk.CairoHelper.Create (args.Window)) + { + Win32GDI GDI_Win32 = Win32GDI.getInstance(); + + if (GDI_Win32.isAvailable()) + { + System.Drawing.Graphics wg = Gtk.DotNet.Graphics.FromDrawable(this.GdkWindow, true); + IntPtr hdc = wg.GetHdc(); + + int i = 0; + int n = 2; + int w = 16; + int h = 16; + + Area[] areas = new Area[n]; + GDI.POINT[][] points = new GDI.POINT[n][]; + + /* Test Case 1 */ + areas[i].X = 0; + areas[i].Y = 0; + areas[i].W = w; + areas[i].H = h; + points[i] = new GDI.POINT[4]; + points[i][0].X = 0; + points[i][0].Y = 15; + points[i][1].X = 8; + points[i][1].Y = 0; + points[i][2].X = 15; + points[i][2].Y = 15; + points[i][3].X = 0; + points[i][3].Y = 15; + i++; + + /* Test Case 2 */ + areas[i].X = 0; + areas[i].Y = 0; + areas[i].W = w; + areas[i].H = h; + points[i] = new GDI.POINT[5]; + points[i][0].X = w * i + 3; + points[i][0].Y = 0 + 3; + points[i][1].X = w * (i + 1) - 3; + points[i][1].Y = 0 + 3; + points[i][2].X = w * (i + 1) - 3; + points[i][2].Y = h - 3; + points[i][3].X = w * i + 3; + points[i][3].Y = h - 3; + points[i][4].X = w * i + 3; + points[i][4].Y = 0 + 3; + i++; + + /* Fill Area with White */ + cg.Color = new Cairo.Color(255,255,255); + Cairo.Rectangle rect = new Cairo.Rectangle(0, 0, n * w, h); + cg.Rectangle(rect); + cg.Fill(); + cg.Stroke(); + + IntPtr blackSolidBrush = GDI_Win32.CreateSolidBrush(0); + IntPtr oldBrush = GDI_Win32.SelectObject(hdc, blackSolidBrush); + + for (i = 0; i < n; i++) + { + GDI_Win32.MoveToEx(hdc, points[i][0].X, points[i][0].Y, IntPtr.Zero); + GDI_Win32.Polygon(hdc, points[i], points[i].Length); + + dumpText += "unsigned char polygon_case_" + (i + 1) + "[" + w * h + "] = \n"; + dumpText += dumpPixelArea(GDI_Win32, hdc, i * w, 0, w, h) + "\n"; + } + } + } + return true; + } + public override String getDumpText() { return dumpText; diff --git a/GdiTest/Win32GDI.cs b/GdiTest/Win32GDI.cs index ff1157b..d2d3526 100644 --- a/GdiTest/Win32GDI.cs +++ b/GdiTest/Win32GDI.cs @@ -199,6 +199,14 @@ namespace GdiTest return false; } + public override bool Polygon(IntPtr hdc, POINT [] lpPoints, int nCount) + { + if (available) + return Callbacks.Polygon(hdc, lpPoints, nCount); + else + return false; + } + public override IntPtr CreateSolidBrush(int crColor) { if (available) -- cgit v1.2.3