public void TestGetImageSize() { var thisImage = new NetImage(); thisImage.LoadImage("../../Resources/1024x768.png"); int width, height; thisImage.GetImageSize(out width, out height); Assert.AreEqual(1024, width); Assert.AreEqual(768, height); }
public void TestRotate90DegreesWithCrop() { const string outputFilePath = "../../Output/Rotate-90_degrees_with_crop.jpg"; int originalWidth = 0; int originalHeight = 0; var thisImage = new NetImage(); thisImage.LoadImage("../../Resources/1024x768.png"); thisImage.GetImageSize(out originalWidth, out originalHeight); thisImage.Filename = outputFilePath; thisImage.RotateImage(90); thisImage.ConstrainResize = true; thisImage.Resize(originalWidth, originalHeight); thisImage.SaveImage(); int width, height; thisImage.GetImageFileSize(outputFilePath, out width, out height); Assert.AreEqual(originalWidth, width); Assert.AreEqual(originalHeight, height); }
public void TestGIMPImage() { const string outputFilePath = "../../Output/gimpimage.jpg"; var thisImage = new NetImage(); thisImage.LoadImage("../../Resources/gimpimage.jpg"); if (thisImage.Error.Length <= 0) { int width = 0; int height = 0; thisImage.GetImageSize(out width, out height); if (width > 0 && height > 0) { thisImage.Filename = outputFilePath; thisImage.SaveImage(); if (thisImage.Error.Length <= 0) { var fileInfo = new System.IO.FileInfo(outputFilePath); Assert.That(fileInfo.Length > 0, "Image filesize is zero bytes"); } else { Assert.Fail("SaveImage() error: " + thisImage.Error); } } else { Assert.Fail("Loaded image sizes incorrect - width: " + width.ToString(CultureInfo.InvariantCulture) + ", height: " + height.ToString(CultureInfo.InvariantCulture)); } } else { Assert.Fail("LoadImage() error: " + thisImage.Error); } }