예제 #1
0
        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;
        }
예제 #2
0
        protected override bool OnExposeEvent(Gdk.EventExpose args)
        {
            using (Context g = Gdk.CairoHelper.Create (args.Window))
            {
                g.LineWidth = 1;
                g.Antialias = Antialias.None;

                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 = 27;
                    int w = 16;
                    int h = 16;
                    int k = 12;

                    Area[] areas = new Area[n];
                    Point[] startp = new Point[n];
                    Point[] endp = new Point[n];
                    int[] rop2 = new int[n - k + 1];

                    /* Test Case 1: (0,0) -> (15,15) */
                    areas[i].X = 0;
                    areas[i].Y = 0;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w - 1;
                    endp[i].Y =   areas[i].Y + h - 1;
                    i++;

                    /* Test Case 2: (15,15) -> (0,0) */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X + w - 1;
                    startp[i].Y = areas[i].Y + h - 1;
                    endp[i].X =   areas[i].X;
                    endp[i].Y =   areas[i].Y;
                    i++;

                    /* Test Case 3: (15,0) -> (0,15) */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X + w - 1;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X;
                    endp[i].Y =   areas[i].Y + h - 1;
                    i++;

                    /* Test Case 4: (0,15) -> (15,0) */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y + h - 1;
                    endp[i].X =   areas[i].X + w - 1;
                    endp[i].Y =   areas[i].Y;
                    i++;

                    /* Test Case 5: (0,8) -> (15,8) */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y + (h / 2);
                    endp[i].X =   areas[i].X + w - 1;
                    endp[i].Y =   areas[i].Y + (h / 2);
                    i++;

                    /* Test Case 6: (15,8) -> (0,8) */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X + w - 1;
                    startp[i].Y = areas[i].Y + (h / 2);
                    endp[i].X =   areas[i].X;
                    endp[i].Y =   areas[i].Y + (h / 2);
                    i++;

                    /* Test Case 7: (8,0) -> (8,15) */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X + (w / 2);
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + (w / 2);
                    endp[i].Y =   areas[i].Y + h - 1;
                    i++;

                    /* Test Case 8: (8,15) -> (8,0) */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X + (w / 2);
                    startp[i].Y = areas[i].Y + h - 1;
                    endp[i].X =   areas[i].X + (w / 2);
                    endp[i].Y =   areas[i].Y;
                    i++;

                    /* Test Case 9: (4,4) -> (12,12) */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X + (w / 4);
                    startp[i].Y = areas[i].Y + (h / 4);
                    endp[i].X =   areas[i].X + 3 * (w / 4);
                    endp[i].Y =   areas[i].Y + 3 * (h / 4);
                    i++;

                    /* Test Case 10: (12,12) -> (4,4) */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X + 3 * (w / 4);
                    startp[i].Y = areas[i].Y + 3 * (h / 4);
                    endp[i].X =   areas[i].X + (w / 4);
                    endp[i].Y =   areas[i].Y + (h / 4);
                    i++;

                    /* Test Case 11: (0,0) -> (+10,+10) */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w + 10;
                    endp[i].Y =   areas[i].Y + h + 10;
                    i++;

                    /* Test Case 12: (0,0) -> (16,16), R2_BLACK */
                    areas[i].X = 0;
                    areas[i].Y = 2 * h;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + h;
                    rop2[i - k + 1] = GDI.R2_BLACK;
                    i++;

                    /* Test Case 13: (0,0) -> (16,16), R2_NOTMERGEPEN */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + h;
                    rop2[i - k + 1] = GDI.R2_NOTMERGEPEN;
                    i++;

                    /* Test Case 14: (0,0) -> (16,16), R2_MASKNOTPEN */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + h;
                    rop2[i - k + 1] = GDI.R2_MASKNOTPEN;
                    i++;

                    /* Test Case 15: (0,0) -> (16,16), R2_NOTCOPYPEN */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + h;
                    rop2[i - k + 1] = GDI.R2_NOTCOPYPEN;
                    i++;

                    /* Test Case 16: (0,0) -> (16,16), R2_MASKPENNOT */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + h;
                    rop2[i - k + 1] = GDI.R2_MASKPENNOT;
                    i++;

                    /* Test Case 17: (0,0) -> (16,16), R2_NOT */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + h;
                    rop2[i - k + 1] = GDI.R2_NOT;
                    i++;

                    /* Test Case 18: (0,0) -> (16,16), R2_XORPEN */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + h;
                    rop2[i - k + 1] = GDI.R2_XORPEN;
                    i++;

                    /* Test Case 19: (0,0) -> (16,16), R2_NOTMASKPEN */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + h;
                    rop2[i - k + 1] = GDI.R2_NOTMASKPEN;
                    i++;

                    /* Test Case 20: (0,0) -> (16,16), R2_MASKPEN */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + h;
                    rop2[i - k + 1] = GDI.R2_MASKPEN;
                    i++;

                    /* Test Case 21: (0,0) -> (16,16), R2_NOTXORPEN */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + h;
                    rop2[i - k + 1] = GDI.R2_NOTXORPEN;
                    i++;

                    /* Test Case 22: (0,0) -> (16,16), R2_NOP */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + h;
                    rop2[i - k + 1] = GDI.R2_NOP;
                    i++;

                    /* Test Case 23: (0,0) -> (16,16), R2_MERGENOTPEN */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + h;
                    rop2[i - k + 1] = GDI.R2_MERGENOTPEN;
                    i++;

                    /* Test Case 24: (0,0) -> (16,16), R2_COPYPEN */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + h;
                    rop2[i - k + 1] = GDI.R2_COPYPEN;
                    i++;

                    /* Test Case 25: (0,0) -> (16,16), R2_MERGEPENNOT */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + h;
                    rop2[i - k + 1] = GDI.R2_MERGEPENNOT;
                    i++;

                    /* Test Case 26: (0,0) -> (16,16), R2_MERGEPEN */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + h;
                    rop2[i - k + 1] = GDI.R2_MERGEPEN;
                    i++;

                    /* Test Case 27: (0,0) -> (16,16), R2_WHITE */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + h;
                    rop2[i - k + 1] = GDI.R2_WHITE;
                    i++;

                    for (i = 0; i < k; i++)
                    {
                        /* Set Clipping Region */
                        IntPtr clippingRegion = GDI_Win32.CreateRectRgn(areas[i].X, areas[i].Y, areas[i].X + areas[i].W, areas[i].Y + areas[i].H);
                        GDI_Win32.SelectClipRgn(hdc, IntPtr.Zero);
                        GDI_Win32.SelectClipRgn(hdc, clippingRegion);

                        /* Fill Area with White */
                        g.Color = new Color(255,255,255);
                        Rectangle rect = new Rectangle(areas[i].X, areas[i].Y, areas[i].W, areas[i].H);
                        g.Rectangle(rect);
                        g.Fill();
                        g.Stroke();

                        /* Render Test Case */
                        IntPtr pen = GDI_Win32.CreatePen(1, 1, 0);
                        IntPtr oldPen = GDI_Win32.SelectObject(hdc, pen);
                        GDI_Win32.MoveToEx(hdc, startp[i].X, startp[i].Y, IntPtr.Zero);
                        GDI_Win32.LineTo(hdc, endp[i].X, endp[i].Y);

                        dumpText += "unsigned char line_to_case_" + (i + 1) + "[" + areas[i].W * areas[i].H + "] = \n";
                        dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    }

                    for (i = k; i < n; i++)
                    {
                        /* Set Clipping Region */
                        IntPtr clippingRegion = GDI_Win32.CreateRectRgn(areas[i].X, areas[i].Y, areas[i].X + areas[i].W, areas[i].Y + areas[i].H);
                        GDI_Win32.SelectClipRgn(hdc, IntPtr.Zero);
                        GDI_Win32.SelectClipRgn(hdc, clippingRegion);

                        /* Fill Area with White */
                        g.Color = new Color(255,255,255);
                        Rectangle rect = new Rectangle(areas[i].X, areas[i].Y, areas[i].W, areas[i].H);
                        g.Rectangle(rect);
                        g.Fill();
                        g.Stroke();

                        /* Render Test Case */
                        GDI_Win32.SetROP2(hdc, rop2[i - k + 1]);
                        IntPtr pen = GDI_Win32.CreatePen(1, 1, 0xFFFFFF);
                        IntPtr oldPen = GDI_Win32.SelectObject(hdc, pen);
                        GDI_Win32.MoveToEx(hdc, startp[i].X, startp[i].Y, IntPtr.Zero);
                        GDI_Win32.LineTo(hdc, endp[i].X, endp[i].Y);

                        dumpText += "unsigned char line_to_case_" + (i + 1) + "[" + areas[i].W * areas[i].H + "] = \n";
                        dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    }
                }
            }

            return true;
        }
예제 #3
0
        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();

                    Area aSrc = new Area();
                    Area aDst = new Area();
                    Area aPat = new Area();

                    aSrc.X = 0;
                    aSrc.Y = 0;
                    aSrc.W = 16;
                    aSrc.H = 16;

                    aDst.X = 16;
                    aDst.Y = 0;
                    aDst.W = 16;
                    aDst.H = 16;

                    aPat.X = 32;
                    aPat.Y = 0;
                    aPat.W = 8;
                    aPat.H = 8;

                    drawBitmap(hdc, aSrc.X, aSrc.Y, bmp_SRC);
                    drawBitmap(hdc, aDst.X, aDst.Y, bmp_DST);
                    drawBitmap(hdc, aPat.X, aPat.Y, bmp_PAT);

                    dumpText += "unsigned char bmp_SRC[" + bmp_SRC.Width * bmp_SRC.Height + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, aSrc.X, aSrc.Y, bmp_SRC.Width, bmp_SRC.Height) + "\n";

                    dumpText += "unsigned char bmp_DST[" + bmp_DST.Width * bmp_DST.Height + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, aDst.X, aDst.Y, bmp_DST.Width, bmp_DST.Height) + "\n";

                    dumpText += "unsigned char bmp_PAT[" + bmp_PAT.Width * bmp_PAT.Height + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, aPat.X, aPat.Y, bmp_PAT.Width, bmp_PAT.Height) + "\n";

                    IntPtr hBrushOld;
                    IntPtr hBrush = GDI_Win32.CreatePatternBrush(bmp_PAT.GetHbitmap());

                    int i = 0;
                    int n = 16;
                    int w = 16;
                    int h = 16;

                    /* Fill Area with White */
                    cg.Color = new Cairo.Color(255,255,255);
                    Cairo.Rectangle rect = new Cairo.Rectangle(0, 32, n * w, h);
                    cg.Rectangle(rect);
                    cg.Fill();
                    cg.Stroke();

                    Area[] areas = new Area[n];

                    /* Test Case 1: SRCCOPY */
                    areas[i].X = 0;
                    areas[i].Y = 32;
                    areas[i].W = w;
                    areas[i].H = h;
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aDst.X, aDst.Y, GDI.SRCCOPY);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aSrc.X, aSrc.Y, GDI.SRCCOPY);
                    dumpText += "unsigned char bmp_SRCCOPY[" + areas[i].W * areas[i].H + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    i++;

                    /* Test Case 2: BLACKNESS */
                    areas[i].X = areas[i - 1].X + w;
                    areas[i].Y = 32;
                    areas[i].W = w;
                    areas[i].H = h;
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aDst.X, aDst.Y, GDI.SRCCOPY);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aSrc.X, aSrc.Y, GDI.BLACKNESS);
                    dumpText += "unsigned char bmp_BLACKNESS[" + areas[i].W * areas[i].H + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    i++;

                    /* Test Case 3: WHITENESS */
                    areas[i].X = areas[i - 1].X + w;
                    areas[i].Y = 32;
                    areas[i].W = w;
                    areas[i].H = h;
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aDst.X, aDst.Y, GDI.SRCCOPY);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aSrc.X, aSrc.Y, GDI.WHITENESS);
                    dumpText += "unsigned char bmp_WHITENESS[" + areas[i].W * areas[i].H + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    i++;

                    /* Test Case 4: SRCAND */
                    areas[i].X = areas[i - 1].X + w;
                    areas[i].Y = 32;
                    areas[i].W = w;
                    areas[i].H = h;
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aDst.X, aDst.Y, GDI.SRCCOPY);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aSrc.X, aSrc.Y, GDI.SRCAND);
                    dumpText += "unsigned char bmp_SRCAND[" + areas[i].W * areas[i].H + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    i++;

                    /* Test Case 5: SRCPAINT */
                    areas[i].X = areas[i - 1].X + w;
                    areas[i].Y = 32;
                    areas[i].W = w;
                    areas[i].H = h;
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aDst.X, aDst.Y, GDI.SRCCOPY);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aSrc.X, aSrc.Y, GDI.SRCPAINT);
                    dumpText += "unsigned char bmp_SRCPAINT[" + areas[i].W * areas[i].H + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    i++;

                    /* Test Case 6: SRCINVERT */
                    areas[i].X = areas[i - 1].X + w;
                    areas[i].Y = 32;
                    areas[i].W = w;
                    areas[i].H = h;
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aDst.X, aDst.Y, GDI.SRCCOPY);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aSrc.X, aSrc.Y, GDI.SRCINVERT);
                    dumpText += "unsigned char bmp_SRCINVERT[" + areas[i].W * areas[i].H + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    i++;

                    /* Test Case 7: SRCERASE */
                    areas[i].X = areas[i - 1].X + w;
                    areas[i].Y = 32;
                    areas[i].W = w;
                    areas[i].H = h;
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aDst.X, aDst.Y, GDI.SRCCOPY);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aSrc.X, aSrc.Y, GDI.SRCERASE);
                    dumpText += "unsigned char bmp_SRCERASE[" + areas[i].W * areas[i].H + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    i++;

                    /* Test Case 8: NOTSRCCOPY */
                    areas[i].X = areas[i - 1].X + w;
                    areas[i].Y = 32;
                    areas[i].W = w;
                    areas[i].H = h;
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aDst.X, aDst.Y, GDI.SRCCOPY);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aSrc.X, aSrc.Y, GDI.NOTSRCCOPY);
                    dumpText += "unsigned char bmp_NOTSRCCOPY[" + areas[i].W * areas[i].H + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    i++;

                    /* Test Case 9: NOTSRCERASE */
                    areas[i].X = areas[i - 1].X + w;
                    areas[i].Y = 32;
                    areas[i].W = w;
                    areas[i].H = h;
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aDst.X, aDst.Y, GDI.SRCCOPY);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aSrc.X, aSrc.Y, GDI.NOTSRCERASE);
                    dumpText += "unsigned char bmp_NOTSRCERASE[" + areas[i].W * areas[i].H + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    i++;

                    /* Test Case 10: DSTINVERT */
                    areas[i].X = areas[i - 1].X + w;
                    areas[i].Y = 32;
                    areas[i].W = w;
                    areas[i].H = h;
                    hBrushOld = GDI_Win32.SelectObject(hdc, hBrush);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aDst.X, aDst.Y, GDI.SRCCOPY);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aSrc.X, aSrc.Y, GDI.DSTINVERT);
                    dumpText += "unsigned char bmp_DSTINVERT[" + areas[i].W * areas[i].H + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    i++;

                    /* Test Case 11: SPna */
                    areas[i].X = areas[i - 1].X + w;
                    areas[i].Y = 32;
                    areas[i].W = w;
                    areas[i].H = h;
                    hBrushOld = GDI_Win32.SelectObject(hdc, hBrush);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aDst.X, aDst.Y, GDI.SRCCOPY);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aSrc.X, aSrc.Y, GDI.SPna);
                    dumpText += "unsigned char bmp_SPna[" + areas[i].W * areas[i].H + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    i++;

                    /* Test Case 12: MERGEPAINT */
                    areas[i].X = areas[i - 1].X + w;
                    areas[i].Y = 32;
                    areas[i].W = w;
                    areas[i].H = h;
                    hBrushOld = GDI_Win32.SelectObject(hdc, hBrush);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aDst.X, aDst.Y, GDI.SRCCOPY);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aSrc.X, aSrc.Y, GDI.MERGEPAINT);
                    dumpText += "unsigned char bmp_MERGEPAINT[" + areas[i].W * areas[i].H + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    i++;

                    /* Test Case 13: MERGECOPY */
                    areas[i].X = areas[i - 1].X + w;
                    areas[i].Y = 32;
                    areas[i].W = w;
                    areas[i].H = h;
                    hBrushOld = GDI_Win32.SelectObject(hdc, hBrush);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aDst.X, aDst.Y, GDI.SRCCOPY);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aSrc.X, aSrc.Y, GDI.MERGECOPY);
                    dumpText += "unsigned char bmp_MERGECOPY[" + areas[i].W * areas[i].H + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    i++;

                    /* Test Case 14: PATPAINT */
                    areas[i].X = areas[i - 1].X + w;
                    areas[i].Y = 32;
                    areas[i].W = w;
                    areas[i].H = h;
                    hBrushOld = GDI_Win32.SelectObject(hdc, hBrush);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aDst.X, aDst.Y, GDI.SRCCOPY);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aSrc.X, aSrc.Y, GDI.PATPAINT);
                    dumpText += "unsigned char bmp_PATPAINT[" + areas[i].W * areas[i].H + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    i++;

                    /* Test Case 15: PATCOPY */
                    areas[i].X = areas[i - 1].X + w;
                    areas[i].Y = 32;
                    areas[i].W = w;
                    areas[i].H = h;
                    hBrushOld = GDI_Win32.SelectObject(hdc, hBrush);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aDst.X, aDst.Y, GDI.SRCCOPY);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aSrc.X, aSrc.Y, GDI.PATCOPY);
                    dumpText += "unsigned char bmp_PATCOPY[" + areas[i].W * areas[i].H + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    i++;

                    /* Test Case 16: PATINVERT */
                    areas[i].X = areas[i - 1].X + w;
                    areas[i].Y = 32;
                    areas[i].W = w;
                    areas[i].H = h;
                    hBrushOld = GDI_Win32.SelectObject(hdc, hBrush);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aDst.X, aDst.Y, GDI.SRCCOPY);
                    GDI_Win32.BitBlt(hdc, areas[i].X, areas[i].Y, aSrc.W, aSrc.H, hdc, aSrc.X, aSrc.Y, GDI.PATINVERT);
                    dumpText += "unsigned char bmp_PATINVERT[" + areas[i].W * areas[i].H + "] = \n";
                    dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    i++;
                }
            }
            return true;
        }
예제 #4
0
        protected override bool OnExposeEvent(Gdk.EventExpose args)
        {
            using (Context g = Gdk.CairoHelper.Create (args.Window))
            {
                g.LineWidth = 1;
                g.Antialias = Antialias.None;

                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 = 10;
                    int w = 16;
                    int h = 16;

                    Area[] areas = new Area[n];
                    Point[] startp = new Point[n];
                    Point[] endp = new Point[n];

                    /* Test Case 1 */
                    areas[i].X = 0;
                    areas[i].Y = 0;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + h;
                    i++;

                    /* Test Case 2 */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X + w;
                    startp[i].Y = areas[i].Y + h;
                    endp[i].X =   areas[i].X;
                    endp[i].Y =   areas[i].Y;
                    i++;

                    /* Test Case 3 */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X + w;
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X;
                    endp[i].Y =   areas[i].Y + h;
                    i++;

                    /* Test Case 4 */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y + h;
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y;
                    i++;

                    /* Test Case 5 */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X;
                    startp[i].Y = areas[i].Y + (h / 2);
                    endp[i].X =   areas[i].X + w;
                    endp[i].Y =   areas[i].Y + (h / 2);
                    i++;

                    /* Test Case 6 */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X + w;
                    startp[i].Y = areas[i].Y + (h / 2);
                    endp[i].X =   areas[i].X;
                    endp[i].Y =   areas[i].Y + (h / 2);
                    i++;

                    /* Test Case 7 */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X + (w / 2);
                    startp[i].Y = areas[i].Y;
                    endp[i].X =   areas[i].X + (w / 2);
                    endp[i].Y =   areas[i].Y + h;
                    i++;

                    /* Test Case 8 */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X + (w / 2);
                    startp[i].Y = areas[i].Y + h;
                    endp[i].X =   areas[i].X + (w / 2);
                    endp[i].Y =   areas[i].Y;
                    i++;

                    /* Test Case 9 */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X + (w / 4);
                    startp[i].Y = areas[i].Y + (h / 4);
                    endp[i].X =   areas[i].X + 3 * (w / 4);
                    endp[i].Y =   areas[i].Y + 3 * (h / 4);
                    i++;

                    /* Test Case 10 */
                    areas[i].X = areas[i - 1].X + areas[i - 1].W;
                    areas[i].Y = areas[i - 1].Y;
                    areas[i].W = w;
                    areas[i].H = h;
                    startp[i].X = areas[i].X + 3 * (w / 4);
                    startp[i].Y = areas[i].Y + (h / 4);
                    endp[i].X =   areas[i].X + (w / 4);
                    endp[i].Y =   areas[i].Y + 3 * (h / 4);
                    i++;

                    for (i = 0; i < n; i++)
                    {
                        if (!rendered)
                        {
                            /* Fill Area with White */
                            g.Color = new Color(255,255,255);
                            Rectangle rect = new Rectangle(areas[i].X, areas[i].Y, areas[i].W, areas[i].H);
                            g.Rectangle(rect);
                            g.Fill();
                            g.Stroke();
                        }

                        /* Render Test Case */
                        IntPtr pen = GDI_Win32.CreatePen(1, 1, 0);
                        IntPtr oldPen = GDI_Win32.SelectObject(hdc, pen);
                        GDI_Win32.MoveToEx(hdc, startp[i].X, startp[i].Y, IntPtr.Zero);
                        GDI_Win32.LineTo(hdc, endp[i].X, endp[i].Y);

                        dumpText += "unsigned char line_to_case_" + (i + 1) + "[" + areas[i].W * areas[i].H + "] = \n";
                        dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n";
                    }
                }
            }

            return true;
        }