|
|
Demonstration of using ColorMatrix
Image im = new Bitmap(@"d:\_\img\kkk.jpg"); ImageAttributes imageAttributes = new ImageAttributes(); float[][] colorMatrixElements = { new float[] {1.0f, 0.0f, 0.0f, 0.0f, 0.0f}, new float[] {0.0f, 1.0f, 0.0f, 0.0f, 0.0f}, new float[] {0.5f, 0.0f, 1.0f, 0.0f, 0.0f}, new float[] {0.0f, 0.0f, 0.0f, 1.0f, 0.0f}, new float[] {0.0f, 0.0f, 0.0f, 0.0f, 1.0f}}; ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElements); imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); e.Graphics.DrawImage(im, new Rectangle(15, 10, im.Width, im.Height), 0, 0, im.Width, im.Height, GraphicsUnit.Pixel, imageAttributes);