Example #1
0
        public void TestLineTo()
        {
            const string outputFilePath = "../../Output/LineTo.png";
            var          redColor       = System.Drawing.Color.FromArgb(255, 255, 0, 0).ToArgb();
            var          blueColor      = System.Drawing.Color.FromArgb(255, 0, 0, 255).ToArgb();

            var thisImage = new NetImage();

            thisImage.BackgroundColor = NetImage.DotNETARGBToVBScriptRGB(System.Drawing.Color.FromArgb(255, 255, 255, 255).ToArgb());
            thisImage.MaxX            = 1024;
            thisImage.MaxY            = 1024;
            thisImage.Filename        = outputFilePath;
            thisImage.ImageFormat     = NetImage.ImageFormats.PNG; // bitmap form to preserve pixels
            thisImage.AutoClear       = false;

            thisImage.X        = 0;
            thisImage.Y        = 0;
            thisImage.PenColor = NetImage.DotNETARGBToVBScriptRGB(redColor);
            thisImage.PenWidth = 1;

            thisImage.LineTo(1023, 1023);
            thisImage.PenColor = NetImage.DotNETARGBToVBScriptRGB(blueColor);
            thisImage.LineTo(1023, 0);

            thisImage.SaveImage();

            // Verify diagonal pixels
            for (int x = 0; x <= 1022; x++) // Only to 1022 because blue line covers up bottom right pixel
            {
                Assert.AreEqual(redColor, NetImage.VBScriptRGBToDotNETARGB(thisImage.GetPixel(x, x)));
            }

            // Verify vertical pixels
            for (int y = 0; y <= 1023; y++)
            {
                Assert.AreEqual(blueColor, NetImage.VBScriptRGBToDotNETARGB(thisImage.GetPixel(1023, y)));
            }
        }