public void Execute(byte[] bytes, int width, int height) { BitmapWrapper bmpWrapper = new BitmapWrapper(bytes, height, width); Color[,] tmpBuffer = new Color[height, width]; for (int j = 1; j < height - 1; j++) { for (int i = 1; i < width - 1; i++) { int r = 0; int g = 0; int b = 0; for (int k = 0; k < 9; k++) { var col = bmpWrapper.GetPixel(j + cordinatesY[k], i + cordinatesX[k]); r += col.R * mask[k]; g += col.G * mask[k]; b += col.B * mask[k]; } int maskSum = mask.Sum(); tmpBuffer[j, i] = Color.FromArgb(255, r / maskSum, g / maskSum, b / maskSum); } } for (int j = 1; j < height - 1; j++) { for (int i = 1; i < width - 1; i++) { bmpWrapper.SetPixel(j, i, tmpBuffer[j, i]); } } }
public void Execute(byte[] bytes, int width, int height) { double contrastLevel = Math.Pow((100.0 + threshold) / 100.0, 2); BitmapWrapper bmpWrapper = new BitmapWrapper(bytes, height, width); for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { Color col = bmpWrapper.GetPixel(j, i); int r = (int)(((((col.R / 255.0) - 0.5) * contrastLevel) + 0.5) * 255.0); int g = (int)(((((col.G / 255.0) - 0.5) * contrastLevel) + 0.5) * 255.0); int b = (int)(((((col.B / 255.0) - 0.5) * contrastLevel) + 0.5) * 255.0); r = Math.Max(0, Math.Min(255, r)); g = Math.Max(0, Math.Min(255, g)); b = Math.Max(0, Math.Min(255, b)); bmpWrapper.SetPixel(j, i, Color.FromArgb(col.A, r, g, b)); } } }
public void Execute(byte[] bytes, int width, int height) { BitmapWrapper bmpWrapper = new BitmapWrapper(bytes, height, width); for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { Color col = bmpWrapper.GetPixel(j, i); bmpWrapper.SetPixel(j, i, Color.FromArgb(col.A, 255 - col.R, 255 - col.G, 255 - col.B)); } } }
public void Execute(byte[] bytes, int width, int height) { BitmapWrapper bmpWrapper = new BitmapWrapper(bytes, height, width); for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { Color col = bmpWrapper.GetPixel(j, i); int grayScale = (int)((col.R * 0.3) + (col.G * 0.59) + (col.B * 0.11)); bmpWrapper.SetPixel(j, i, Color.FromArgb(col.A, grayScale, grayScale, grayScale)); } } }
public void Execute(byte[] bytes, int width, int height) { BitmapWrapper bmpWrapper = new BitmapWrapper(bytes, height, width); Color[,] tmpBuffer = new Color[height, width]; for (int j = 1; j < height - 1; j++) { for (int i = 1; i < width - 1; i++) { int rx = 0; int gx = 0; int bx = 0; int ry = 0; int gy = 0; int by = 0; for (int k = 0; k < 9; k++) { var col = bmpWrapper.GetPixel(j + cordinatesY[k], i + cordinatesX[k]); rx += col.R * maskX[k]; gx += col.G * maskX[k]; bx += col.B * maskX[k]; ry += col.R * maskY[k]; gy += col.G * maskY[k]; by += col.B * maskY[k]; } int r = Math.Abs(rx + ry); int g = Math.Abs(gx + gy); int b = Math.Abs(bx + by); r = Math.Max(0, Math.Min(255, r)); g = Math.Max(0, Math.Min(255, g)); b = Math.Max(0, Math.Min(255, b)); tmpBuffer[j, i] = Color.FromArgb(255, r, g, b); } } for (int j = 1; j < height - 1; j++) { for (int i = 1; i < width - 1; i++) { bmpWrapper.SetPixel(j, i, tmpBuffer[j, i]); } } }
public void Execute(byte[] bytes, int width, int height) { BitmapWrapper bmpWrapper = new BitmapWrapper(bytes, height, width); Color[,] tmpBuffer = new Color[height, width]; for (int j = 1; j < height - 1; j++) { for (int i = 1; i < width - 1; i++) { int fr = 0; int fg = 0; int fb = 0; int sr = 0; int sg = 0; int sb = 0; for (int k = 0; k < 4; k++) { var col = bmpWrapper.GetPixel(j + cordinatesY[k], i + cordinatesX[k]); fr += col.R * firstMask[k]; fg += col.G * firstMask[k]; fb += col.B * firstMask[k]; sr += col.R * secondMask[k]; sg += col.G * secondMask[k]; sb += col.B * secondMask[k]; } fr = Math.Abs(fr); fg = Math.Abs(fg); fb = Math.Abs(fb); sr = Math.Abs(sr); sg = Math.Abs(sg); sb = Math.Abs(sb); tmpBuffer[j, i] = Color.FromArgb(255, TruncateColor(fr + sr), TruncateColor(fg + sg), TruncateColor(fb + sb)); } } for (int j = 1; j < height - 1; j++) { for (int i = 1; i < width - 1; i++) { bmpWrapper.SetPixel(j, i, tmpBuffer[j, i]); } } }