private void FastConver() { Random rnd = new Random(); double[,] matrix = random(); /*{ * { 0.01, 0.02, 0.03, 0.04, 0.05 }, * {-0.75,0,0.2,1,-1 }, * { 0,0,-0.2,1,-1}, * { 0,-0.5,0.2,1,-1}, * { 0,0,-0.2,1,-1} * }; */ UnsafeBitmap bmp2 = new UnsafeBitmap((Bitmap)pictureBox1.Image.Clone()); int x, y; double r = 0, g = 0, b = 0; PixelData c = new PixelData(); swatch.Start(); bmp2.LockBitmap(); for (y = 2; y < bmp2.Bitmap.Height - 2; y++) { for (x = 2; x < bmp2.Bitmap.Width - 2; x++) { r = 0; g = 0; b = 0; for (int i = -2; i < 3; i++) { for (int j = -2; j < 3; j++) { c = bmp2.GetPixel(x + i, y + j); //r += c.R / 25; g += c.G / 25; b += c.B / 25; r += c.R * matrix[i + 2, j + 2]; g += c.G * matrix[i + 2, j + 2]; b += c.B * matrix[i + 2, j + 2]; } } r = r < 0 ? 0 : (r > 255) ? 255 : r; g = g < 0 ? 0 : (g > 255) ? 255 : g; b = b < 0 ? 0 : (b > 255) ? 255 : b; c.R = (byte)r; c.G = (byte)g; c.B = (byte)b; bmp2.SetPixel(x, y, c); } } bmp2.UnlockBitmap(); swatch.Stop(); pictureBox2.Image = bmp2.Bitmap; }
public void SetPixel(int x, int y, PixelData colour) { PixelData *pixel = PixelAt(x, y); *pixel = colour; }
public PixelData GetPixel(int x, int y) { PixelData returnValue = *PixelAt(x, y); return(returnValue); }