コード例 #1
0
        public void TestFillRect()
        {
            const string outputFilePath = "../../Output/FillRect.png";

            var thisImage = new NetImage();

            thisImage.LoadImage("../../Resources/1024x768-white.png");
            thisImage.ImageFormat     = NetImage.ImageFormats.PNG;
            thisImage.Filename        = outputFilePath;
            thisImage.BackgroundColor = NetImage.DotNETARGBToVBScriptRGB(Color.Red.ToArgb());
            thisImage.FillRect(10, 10, 20, 20);
            thisImage.AutoClear = false; // Don't clear on save so we can still access raw image
            thisImage.SaveImage();

            var color1 = ((Bitmap)thisImage.RawNetImage).GetPixel(9, 9).ToArgb();
            var color2 = ((Bitmap)thisImage.RawNetImage).GetPixel(10, 10).ToArgb();
            var color3 = ((Bitmap)thisImage.RawNetImage).GetPixel(20, 20).ToArgb();
            var color4 = ((Bitmap)thisImage.RawNetImage).GetPixel(21, 21).ToArgb();

            Assert.AreEqual(Color.White.ToArgb(), color1);
            Assert.AreEqual(Color.Red.ToArgb(), color2);
            Assert.AreEqual(Color.Red.ToArgb(), color3);
            Assert.AreEqual(Color.White.ToArgb(), color4);
        }