You simply create the corresponding ColorMatrix, initialize the ImageAttributes object and pass that ImageAttributes object to one of the overloaded version of Graphics.DrawImage. This sample will give you 50% transparency:
float[][] matrixAlpha = { new float[] {1, 0, 0, 0, 0}, new float[] {0, 1, 0, 0, 0}, new float[] {0, 0, 1, 0, 0}, new float[] {0, 0, 0, 0.5f, 0}, new float[] {0, 0, 0, 0, 1} }; ColorMatrix colorMatrix = new ColorMatrix( matrixAlpha ); ImageAttributes iaAlphaBlend = new ImageAttributes(); iaAlphaBlend.SetColorMatrix( colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap );
source share