rendered paste bodyint[,] newRed = new int[width,height];
int[,] newGreen = new int[width, height];
int[,] newBlue = new int[width, height];
int[,] oldRed = new int[width, height];
int[,] oldGreen = new int[width, height];
int[,] oldBlue = new int[width, height];
BitmapData bitmapData = newBitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
IntPtr ptr = bitmapData.Scan0;
int bytes = width * height * 4;
byte[] rgbValues = new byte[bytes];
System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);
for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++)
{
int counter = (x + (Math.Max(0,(y-1) * width))) * 4;
oldRed[x, y] = rgbValues[counter + 2];
oldGreen[x, y] = rgbValues[counter + 1];
oldBlue[x, y] = rgbValues[counter];
}
newRed = redColorMatrix(oldRed, width, height);
newGreen = greenColorMatrix(oldGreen, width, height);
newBlue = blueColorMatrix(oldBlue, width, height);
for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++)
{
int counter = (x + (Math.Max(0, (y - 1) * width)))*4;
rgbValues[counter + 2] = (byte)newRed[x, y];
rgbValues[counter + 1] = (byte)newGreen[x, y];
rgbValues[counter] = (byte)newBlue[x, y];
}
System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes);
newBitmap.UnlockBits(bitmapData);