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))); } }
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); }