public void TestGetPixel() { var thisImage = new NetImage(); thisImage.ImageFormat = NetImage.ImageFormats.PNG; // No image data yet, value returned is zero var pixelColor = thisImage.GetPixel(640, 480); Assert.AreEqual(0, pixelColor); // Initialize image thisImage.BackgroundColor = NetImage.DotNETARGBToVBScriptRGB(0x32FF0000); thisImage.MaxX = 1024; thisImage.MaxY = 768; pixelColor = thisImage.GetPixel(640, 480); // Backgrounds can only be solid colors Assert.AreEqual(System.Drawing.Color.FromArgb(255, 255, 0, 0).ToArgb(), NetImage.VBScriptRGBToDotNETARGB(pixelColor)); // Verify color change thisImage.BackgroundColor = NetImage.DotNETARGBToVBScriptRGB(System.Drawing.Color.FromArgb(50, 0, 0, 255).ToArgb()); thisImage.ClearImage(); pixelColor = thisImage.GetPixel(640, 480); Assert.AreEqual(System.Drawing.Color.FromArgb(255, 0, 0, 255).ToArgb(), NetImage.VBScriptRGBToDotNETARGB(pixelColor)); }
public void TestPropertyFontColor() { var thisImage = new NetImage(); const int testValue = -8421505; //System.Drawing.Color.FromArgb(255, 127, 127, 127).ToArgb(); thisImage.FontColor = NetImage.DotNETARGBToVBScriptRGB(System.Drawing.Color.FromArgb(255, 127, 127, 127).ToArgb()); Assert.AreEqual(testValue, NetImage.VBScriptRGBToDotNETARGB(thisImage.FontColor)); }
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))); } }