コード例 #1
0
        public void OverlayImageWithCutEllipseTest()
        {
            string image1Path = AppDomain.CurrentDomain.BaseDirectory + @"\UI\head-frame.png";
            string image2Path = AppDomain.CurrentDomain.BaseDirectory + @"\UI\demo2.jpg";

            Assert.IsNotNull(string.IsNullOrEmpty(image1Path));
            Assert.IsTrue(System.IO.File.Exists(image1Path));
            Image image1 = Image.FromFile(image1Path);

            Assert.IsNotNull(image1);
            image1.Save(image1Path.Replace(".png", "-raw-OverlayImageWithCutEllipseTest.png"), System.Drawing.Imaging.ImageFormat.Png);

            Assert.IsNotNull(string.IsNullOrEmpty(image2Path));
            Assert.IsTrue(System.IO.File.Exists(image2Path));
            Image image2 = Image.FromFile(image2Path);

            Assert.IsNotNull(image2);
            image2.Save(image2Path.Replace(".jpg", "-raw-OverlayImageWithCutEllipseTest.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);

            Image result = GDIHelper.OverlayImageWithCutEllipse(image1, image2, new Rectangle(image2.Width / 50 * 20, image2.Height / 16 * 1, image2.Width / 7, image2.Width / 7),
                                                                1.0F, new Point(image1.Width / 7, image1.Height / 7), new Size(image1.Width / 7 * 5, image1.Height / 7 * 5),
                                                                new Size(image1.Width / 3 * 2, image1.Height / 3 * 2));

            string resultPath = AppDomain.CurrentDomain.BaseDirectory + @"\UI\OverlayImageWithCutEllipseTest-result.png";

            result.Save(resultPath, System.Drawing.Imaging.ImageFormat.Png);
        }