예제 #1
0
파일: Pen.cs 프로젝트: pmq20/mono_forked
 public void SetUp()
 {
     t       = DrawingTest.Create(256, 256);
     p       = new Pen(Color.Blue);
     p.Width = 10;
     DrawingTest.ShowForms = false;
 }
예제 #2
0
        public void SetUp()
        {
            t = DrawingTest.Create(256, 256);
            Image im = new Bitmap("Bitmap1.png");

            t.Graphics.DrawImageUnscaled(im, 0, 0);
        }
예제 #3
0
        public void Clone2()
        {
            Image im1 = (Image)t.Bitmap.Clone(new Rectangle(0, 0, t.Bitmap.Width, t.Bitmap.Height), t.Bitmap.PixelFormat);

            t.Graphics.FillRectangle(Brushes.Beige, 0, 0, 100, 100);
            Assert.IsFalse(DrawingTest.CalculateNorm((Bitmap)im1) ==
                           DrawingTest.CalculateNorm(t.Bitmap));
        }
예제 #4
0
        public void SetUp()
        {
            t = DrawingTest.Create(64, 64);
            Bitmap b = new Bitmap("Bitmap1.png");

            t.Graphics.DrawImageUnscaled(b, 0, 0);
            DrawingTest.ShowForms = false;
        }
예제 #5
0
 public void Save_string_ImageFormat()
 {
     t.Bitmap.Save("test.png", ImageFormat.Png);
     using (FileStream r = new FileStream("test.png", FileMode.Open)) {
         Bitmap b1 = new Bitmap(r);
         Assert.AreEqual(DrawingTest.CalculateNorm(t.Bitmap),
                         DrawingTest.CalculateNorm(b1));
     }
     File.Delete("test.png");
 }
예제 #6
0
        public void Clone()
        {
            Image im1 = (Image)t.Bitmap.Clone();

            Assert.IsFalse(Object.ReferenceEquals(im1, t.Bitmap));
            Assert.AreEqual(DrawingTest.CalculateNorm((Bitmap)im1),
                            DrawingTest.CalculateNorm(t.Bitmap));
            t.Graphics.FillRectangle(Brushes.Beige, 0, 0, 100, 100);
            Assert.IsFalse(DrawingTest.CalculateNorm((Bitmap)im1) ==
                           DrawingTest.CalculateNorm(t.Bitmap));
        }
예제 #7
0
        public void CloneTest()
        {
            Bitmap b1 = (Bitmap)t.Bitmap.Clone();

            Assert.IsFalse(Object.ReferenceEquals(t.Bitmap, b1));
            Assert.AreEqual(DrawingTest.CalculateNorm(t.Bitmap),
                            DrawingTest.CalculateNorm(b1));
            t.Graphics.FillRectangle(Brushes.Black, 0, 0, 64, 64);
            Assert.IsFalse(DrawingTest.CalculateNorm(t.Bitmap) ==
                           DrawingTest.CalculateNorm(b1));
        }
예제 #8
0
        public virtual void CopyData()
        {
            GraphicsPath path = new GraphicsPath();

            path.AddLine(new Point(100, 100), new Point(400, 100));
            path.AddLine(new Point(400, 200), new Point(10, 100));
            path.StartFigure();
            path.SetMarkers();
            path.AddRectangle(new Rectangle(10, 20, 300, 400));
            path.StartFigure();
            path.SetMarkers();
            path.AddLine(new Point(400, 400), new Point(400, 10));

            GraphicsPathIterator pathIterator = new GraphicsPathIterator(path);

            pathIterator.Rewind();
            PointF [] actualPoints = new PointF [10];
            byte []   actualTypes  = new byte [10];
            pathIterator.CopyData(ref actualPoints, ref actualTypes, 0, 9);

            PointF [] expectedPoints = new PointF [] { new PointF(100f, 100f),
                                                       new PointF(400f, 100f),
                                                       new PointF(400f, 200f),
                                                       new PointF(10f, 100f),
                                                       new PointF(10f, 20f),
                                                       new PointF(310f, 20f),
                                                       new PointF(310f, 420f),
                                                       new PointF(10f, 420f),
                                                       new PointF(400f, 400f),
                                                       new PointF(400f, 10f) };

            for (int i = 0; i < expectedPoints.Length; i++)
            {
                DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
            }

            byte [] expectedTypes = new byte [] { (byte)PathPointType.Start,
                                                  (byte)PathPointType.Line,
                                                  (byte)PathPointType.Line,
                                                  (byte)(PathPointType.Line | PathPointType.PathMarker),
                                                  (byte)PathPointType.Start,
                                                  (byte)PathPointType.Line,
                                                  (byte)PathPointType.Line,
                                                  (byte)(PathPointType.Line | PathPointType.CloseSubpath | PathPointType.PathMarker),
                                                  (byte)PathPointType.Start,
                                                  (byte)PathPointType.Line };

            for (int i = 0; i < expectedTypes.Length; i++)
            {
                Assert.AreEqual(expectedTypes [i], actualTypes [i]);
            }
        }
예제 #9
0
        public void ColorTest()
        {
            SolidBrush b = new SolidBrush(Color.Azure);

            Assert.AreEqual(Color.Azure, b.Color);
            DrawingTest t = DrawingTest.Create(64, 64);

            t.Graphics.FillRectangle(b, 0, 0, 30, 30);
            t.Show();
            b.Color = Color.FromArgb(100, 240, 30);
            t.Graphics.FillRectangle(b, 30, 5, 30, 50);
            t.Show();
            b.Color = Color.FromArgb(70, Color.FromName("red"));
            t.Graphics.FillRectangle(b, 15, 15, 40, 40);
            t.Show();
        }
예제 #10
0
 public void Save_string_ImageCodecInfo_EncoderParameters()
 {
     foreach (ImageCodecInfo i in ImageCodecInfo.GetImageEncoders())
     {
         if (i.FilenameExtension.ToLower().IndexOf("png") != -1)
         {
             t.Bitmap.Save("test.png", i, new EncoderParameters());
             break;
         }
     }
     using (FileStream r = new FileStream("test.png", FileMode.Open)) {
         Bitmap b1 = new Bitmap(r);
         Assert.AreEqual(DrawingTest.CalculateNorm(t.Bitmap),
                         DrawingTest.CalculateNorm(b1));
     }
     File.Delete("test.png");
 }
예제 #11
0
        public virtual void NextSubpath_GraphicsPath_Bool()
        {
            GraphicsPath path = new GraphicsPath();

            path.AddLine(new Point(100, 100), new Point(400, 100));
            path.AddLine(new Point(400, 200), new Point(10, 100));
            path.StartFigure();
            path.SetMarkers();
            path.AddBezier(10, 10, 50, 250, 100, 5, 200, 280);
            path.CloseFigure();
            path.StartFigure();
            path.SetMarkers();
            path.AddRectangle(new Rectangle(10, 20, 300, 400));
            path.StartFigure();
            path.SetMarkers();
            path.AddLine(new Point(400, 400), new Point(400, 10));

            GraphicsPathIterator iterator = new GraphicsPathIterator(path);
            GraphicsPath         path2    = new GraphicsPath();

            bool isClosed;

            int count = iterator.NextSubpath(path2, out isClosed);

            Assert.AreEqual(4, count);
            Assert.IsFalse(isClosed);

            PointF [] actualPoints = path2.PathPoints;
            byte []   actualTypes  = path2.PathTypes;

            PointF [] expectedPoints = new PointF [] { new PointF(100f, 100f),
                                                       new PointF(400f, 100f),
                                                       new PointF(400f, 200f),
                                                       new PointF(10f, 100f) };

            for (int i = 0; i < expectedPoints.Length; i++)
            {
                DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
            }

            byte [] expectedTypes = new byte [] { (byte)PathPointType.Start,
                                                  (byte)PathPointType.Line,
                                                  (byte)PathPointType.Line,
                                                  (byte)(PathPointType.Line | PathPointType.PathMarker) };

            for (int i = 0; i < expectedTypes.Length; i++)
            {
                Assert.AreEqual(expectedTypes [i], actualTypes [i]);
            }

            count = iterator.NextSubpath(path2, out isClosed);
            Assert.AreEqual(4, count);
            Assert.IsTrue(isClosed);

            actualPoints = path2.PathPoints;
            actualTypes  = path2.PathTypes;

            expectedPoints = new PointF [] { new PointF(10f, 10f),
                                             new PointF(50f, 250f),
                                             new PointF(100f, 5f),
                                             new PointF(200f, 280f) };

            for (int i = 0; i < expectedPoints.Length; i++)
            {
                DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
            }

            expectedTypes = new byte [] { (byte)PathPointType.Start,
                                          (byte)PathPointType.Bezier3,
                                          (byte)PathPointType.Bezier3,
                                          (byte)(PathPointType.Bezier3 | PathPointType.CloseSubpath | PathPointType.PathMarker) };

            for (int i = 0; i < expectedTypes.Length; i++)
            {
                Assert.AreEqual(expectedTypes [i], actualTypes [i]);
            }

            count = iterator.NextSubpath(path2, out isClosed);
            Assert.AreEqual(4, count);
            Assert.IsTrue(isClosed);

            actualPoints = path2.PathPoints;
            actualTypes  = path2.PathTypes;

            expectedPoints = new PointF [] { new PointF(10f, 20f),
                                             new PointF(310f, 20f),
                                             new PointF(310f, 420f),
                                             new PointF(10f, 420f) };

            for (int i = 0; i < expectedPoints.Length; i++)
            {
                DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
            }

            expectedTypes = new byte [] { (byte)PathPointType.Start,
                                          (byte)PathPointType.Line,
                                          (byte)PathPointType.Line,
                                          (byte)(PathPointType.Line | PathPointType.CloseSubpath | PathPointType.PathMarker) };

            for (int i = 0; i < expectedTypes.Length; i++)
            {
                Assert.AreEqual(expectedTypes [i], actualTypes [i]);
            }

            count = iterator.NextSubpath(path2, out isClosed);
            Assert.AreEqual(2, count);
            Assert.IsFalse(isClosed);

            actualPoints = path2.PathPoints;
            actualTypes  = path2.PathTypes;

            expectedPoints = new PointF [] { new PointF(400f, 400f),
                                             new PointF(400f, 10f) };

            for (int i = 0; i < expectedPoints.Length; i++)
            {
                DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
            }

            expectedTypes = new byte [] { (byte)PathPointType.Start,
                                          (byte)PathPointType.Line };

            for (int i = 0; i < expectedTypes.Length; i++)
            {
                Assert.AreEqual(expectedTypes [i], actualTypes [i]);
            }

            count = iterator.NextSubpath(path2, out isClosed);
            Assert.AreEqual(0, count);

            count = iterator.NextSubpath(path2, out isClosed);
            Assert.AreEqual(0, count);
            Assert.IsTrue(isClosed);
            Assert.AreEqual(2, path2.PointCount);

            actualPoints = path2.PathPoints;
            actualTypes  = path2.PathTypes;

            expectedPoints = new PointF [] { new PointF(400f, 400f),
                                             new PointF(400f, 10f) };

            for (int i = 0; i < expectedPoints.Length; i++)
            {
                DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
            }

            expectedTypes = new byte [] { (byte)PathPointType.Start,
                                          (byte)PathPointType.Line };

            for (int i = 0; i < expectedTypes.Length; i++)
            {
                Assert.AreEqual(expectedTypes [i], actualTypes [i]);
            }

            path = new GraphicsPath();
            path.AddBezier(10, 10, 50, 250, 100, 5, 200, 280);
            iterator = new GraphicsPathIterator(path);

            path2 = new GraphicsPath();
            count = iterator.NextSubpath(path2, out isClosed);
            Assert.AreEqual(4, count);
            Assert.IsFalse(isClosed);

            path2 = new GraphicsPath();
            count = iterator.NextSubpath(path2, out isClosed);
            Assert.AreEqual(0, count);
            Assert.IsTrue(isClosed);
        }
예제 #12
0
        public virtual void Enumerate()
        {
            GraphicsPath path = new GraphicsPath();

            path.AddLine(new Point(100, 100), new Point(400, 100));
            path.AddLine(new Point(400, 200), new Point(10, 100));

            path.StartFigure();
            path.AddBezier(10, 10, 50, 250, 100, 5, 200, 280);
            path.StartFigure();
            path.AddRectangle(new Rectangle(10, 20, 300, 400));

            path.StartFigure();
            path.AddLine(new Point(400, 400), new Point(400, 10));

            path.Reverse();

            GraphicsPathIterator iterator = new GraphicsPathIterator(path);

            PointF [] actualPoints = new PointF [14];
            byte []   actualTypes  = new byte [14];
            iterator.Enumerate(ref actualPoints, ref actualTypes);

            PointF [] expectedPoints = new PointF [] { new PointF(400f, 10f),
                                                       new PointF(400f, 400f),
                                                       new PointF(10f, 420f),
                                                       new PointF(310f, 420f),
                                                       new PointF(310f, 20f),
                                                       new PointF(10f, 20f),
                                                       new PointF(200f, 280f),
                                                       new PointF(100f, 5f),
                                                       new PointF(50f, 250f),
                                                       new PointF(10f, 10f),
                                                       new PointF(10f, 100f),
                                                       new PointF(400f, 200f),
                                                       new PointF(400f, 100f),
                                                       new PointF(100f, 100f) };

            for (int i = 0; i < expectedPoints.Length; i++)
            {
                DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
            }

            byte [] expectedTypes = new byte [] { (byte)PathPointType.Start,
                                                  (byte)PathPointType.Line,
                                                  (byte)PathPointType.Start,
                                                  (byte)PathPointType.Line,
                                                  (byte)PathPointType.Line,
                                                  (byte)(PathPointType.Line | PathPointType.CloseSubpath),
                                                  (byte)PathPointType.Start,
                                                  (byte)PathPointType.Bezier3,
                                                  (byte)PathPointType.Bezier3,
                                                  (byte)PathPointType.Bezier3,
                                                  (byte)PathPointType.Start,
                                                  (byte)PathPointType.Line,
                                                  (byte)PathPointType.Line,
                                                  (byte)PathPointType.Line };

            for (int i = 0; i < expectedTypes.Length; i++)
            {
                Assert.AreEqual(expectedTypes [i], actualTypes [i]);
            }
        }
예제 #13
0
        public virtual void NextMarker_GraphicsPath()
        {
            GraphicsPath path = new GraphicsPath();

            path.AddLine(new Point(100, 100), new Point(400, 100));
            path.AddLine(new Point(400, 200), new Point(10, 100));
            path.StartFigure();
            path.SetMarkers();
            path.AddBezier(10, 10, 50, 250, 100, 5, 200, 280);
            path.StartFigure();
            path.SetMarkers();
            path.AddRectangle(new Rectangle(10, 20, 300, 400));
            path.StartFigure();
            path.SetMarkers();
            path.AddLine(new Point(400, 400), new Point(400, 10));

            GraphicsPath path2 = new GraphicsPath();

            path.AddLine(new Point(150, 150), new Point(450, 150));
            path.AddLine(new Point(450, 250), new Point(50, 150));

            GraphicsPathIterator iterator = new GraphicsPathIterator(path);

            iterator.NextMarker(null);
            iterator.NextMarker(path2);

            Assert.AreEqual(4, path2.PointCount);
            PointF [] actualPoints = path2.PathPoints;
            byte []   actualTypes  = path2.PathTypes;

            PointF [] expectedPoints = new PointF [] { new PointF(100f, 100f),
                                                       new PointF(400f, 100f),
                                                       new PointF(400f, 200f),
                                                       new PointF(10f, 100f) };

            for (int i = 0; i < expectedPoints.Length; i++)
            {
                DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
            }

            byte [] expectedTypes = new byte [] { (byte)PathPointType.Start,
                                                  (byte)PathPointType.Line,
                                                  (byte)PathPointType.Line,
                                                  (byte)(PathPointType.Line | PathPointType.PathMarker) };

            for (int i = 0; i < expectedTypes.Length; i++)
            {
                Assert.AreEqual(expectedTypes [i], actualTypes [i]);
            }

            iterator.NextMarker(null);
            iterator.NextMarker(null);
            iterator.NextMarker(null);
            iterator.NextMarker(path2);

            Assert.AreEqual(4, path2.PointCount);
            actualPoints = path2.PathPoints;
            actualTypes  = path2.PathTypes;

            expectedPoints = new PointF [] { new PointF(10f, 10f),
                                             new PointF(50f, 250f),
                                             new PointF(100f, 5f),
                                             new PointF(200f, 280f) };

            for (int i = 0; i < expectedPoints.Length; i++)
            {
                DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
            }

            expectedTypes = new byte [] { (byte)PathPointType.Start,
                                          (byte)PathPointType.Bezier3,
                                          (byte)PathPointType.Bezier3,
                                          (byte)(PathPointType.Bezier3 | PathPointType.PathMarker) };

            for (int i = 0; i < expectedTypes.Length; i++)
            {
                Assert.AreEqual(expectedTypes [i], actualTypes [i]);
            }
        }
예제 #14
0
 public void SetUp()
 {
     t    = DrawingTest.Create(1000, 1000);
     rect = new RectangleF(50, 50, 50, 50);
     r    = new Region(rect);
 }
예제 #15
0
 public virtual void SetUp(string ownerClass)
 {
     t    = DrawingTest.Create(512, 512, ownerClass);
     bmp  = Bitmap.FromFile("bitmap50.png");
     bmp2 = Bitmap.FromFile("bitmap25.png");
 }