public void ApplyTreshold(int level) { var oldR = LargeBitmap.GetPixel(0, 0).R; var oldG = LargeBitmap.GetPixel(0, 0).G; var oldB = LargeBitmap.GetPixel(0, 0).B; int intensity = (oldR + oldG + oldB) / 3; int newR; int newG; int newB; if (intensity >= 255 * level / 100) { newR = 255; newG = 255; newB = 255; } else { newR = 0; newG = 0; newB = 0; } ImageHandler.ApplyThreshold(LargeBitmap, level); Assert.AreEqual(newR, LargeBitmap.GetPixel(0, 0).R); Assert.AreEqual(newG, LargeBitmap.GetPixel(0, 0).G); Assert.AreEqual(newB, LargeBitmap.GetPixel(0, 0).B); }
public void ApplyGrayscale() { var oldR = LargeBitmap.GetPixel(0, 0).R; var oldG = LargeBitmap.GetPixel(0, 0).G; var oldB = LargeBitmap.GetPixel(0, 0).B; int intensity = (oldR + oldG + oldB) / 3; int newR = intensity; int newG = intensity; int newB = intensity; ImageHandler.ApplyGrayscale(LargeBitmap); Assert.AreEqual(newR, LargeBitmap.GetPixel(0, 0).R); Assert.AreEqual(newG, LargeBitmap.GetPixel(0, 0).G); Assert.AreEqual(newB, LargeBitmap.GetPixel(0, 0).B); }
public void ApplySepia() { var oldR = LargeBitmap.GetPixel(0, 0).R; var oldG = LargeBitmap.GetPixel(0, 0).G; var oldB = LargeBitmap.GetPixel(0, 0).B; int newR = (int)(oldR * 0.393f + oldG * 0.769f + oldB * 0.189f); int newG = (int)(oldR * 0.349f + oldG * 0.686f + oldB * 0.168f); int newB = (int)(oldR * 0.272f + oldG * 0.543f + oldB * 0.131f); newR = newR > 255 ? 255 : newR; newG = newG > 255 ? 255 : newG; newB = newB > 255 ? 255 : newB; ImageHandler.ApplySepia(LargeBitmap); Assert.AreEqual(newR, LargeBitmap.GetPixel(0, 0).R); Assert.AreEqual(newG, LargeBitmap.GetPixel(0, 0).G); Assert.AreEqual(newB, LargeBitmap.GetPixel(0, 0).B); }