private Color AverageColor(CopyableBitmap image, Int32Rect area) { byte[,] pixels = (byte[, ])image.GetPixelChannels(area).Clone(); int[] channelSums = SumPixelChannels(pixels); Color averageColor = new Color(); averageColor.B = (byte)(channelSums[0] / pixels.GetLength(1)); averageColor.G = (byte)(channelSums[1] / pixels.GetLength(1)); averageColor.R = (byte)(channelSums[2] / pixels.GetLength(1)); averageColor.A = (byte)(channelSums[3] / pixels.GetLength(1)); return(averageColor); }
// gets the color value of surrounding pixels, and returns that information as a list of byte arrays private List <byte[]> GetSurroundingColors(int x, int y, CopyableBitmap image) { List <byte[]> capturedPixels = new List <byte[]>(); for (int verticalDifference = -5; verticalDifference <= 5; verticalDifference++) { for (int horizontalDifference = -5; horizontalDifference <= 5; horizontalDifference++) { byte[] colors = image.GetPixelBytes(x + horizontalDifference, y + verticalDifference); if (colors != null) { capturedPixels.Add(colors); } } } return(capturedPixels); }
public Greyalizer(CopyableBitmap inputImage) { _inputImage = inputImage; }
public Blurer(CopyableBitmap inputImage) { _inputImage = inputImage; }
public static EditableBitmap Blur(CopyableBitmap inputImage) { Blurer blurer = new Blurer(inputImage); return(blurer.Blur()); }
public static EditableBitmap Greyalize(CopyableBitmap inputImage) { Greyalizer greyalizer = new Greyalizer(inputImage); return(greyalizer.Greyalize()); }
public static EditableBitmap Pixelize(CopyableBitmap inputImage) { Pixelizer pixelizer = new Pixelizer(inputImage, 5, 5); return(pixelizer.Pixelize()); }
public Pixelizer(CopyableBitmap inputImage, int spacingX, int spacingY) { _inputImage = inputImage; _spacingX = spacingX; _spacingY = spacingY; }