public void TestCombineAllWithNegative() { string resourcePath = "Freedom35.ImageProcessing.Tests.Resources.clock.bmp"; // Load source image using Image sourceImage = TestImage.FromResource(resourcePath); Assert.IsNotNull(sourceImage); using Image negativeCopy = ImageColor.ToNegative(sourceImage); Assert.IsNotNull(negativeCopy); Image[] imagesToCombine = new Image[] { sourceImage, negativeCopy }; Bitmap combinedImage = ImageCombine.All(imagesToCombine); // Get bytes for images byte[] combinedBytes = ImageBytes.FromImage(combinedImage); // Just check first row of bytes has been combined for (int i = 0; i < combinedImage.Width; i++) { Assert.AreEqual(byte.MaxValue, combinedBytes[i]); } int pixelDepth = 3; int stride = 1056; int width = 1053; int height = combinedImage.Height; int limit = combinedBytes.Length - 4; // Compare combined bytes excluding stride padding for (int y = 0; y < height; y++) { int offset = y * stride; for (int x = 0; x < width; x += pixelDepth) { int i = offset + x; if (i < limit) { Assert.AreEqual(byte.MaxValue, combinedBytes[i]); } else { break; } } } }
public void TestConvertToNegative() { byte[] imageBytes = { 0x01, 0xf0, 0x3c }; ImageColor.ToNegative(imageBytes); Assert.AreEqual(0xfe, imageBytes[0]); Assert.AreEqual(0x0f, imageBytes[1]); Assert.AreEqual(0xc3, imageBytes[2]); }