1
2 public static Image SetOpacity(Image original, float opacity)
3 {
4 Bitmap temp = new Bitmap(original.Width, original.Height);
5 Graphics g = Graphics.FromImage(temp);
6 ColorMatrix cm = new ColorMatrix();
7 cm.Matrix33 = opacity;
8
9 ImageAttributes ia = new ImageAttributes();
10 ia.SetColorMatrix(cm, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
11 g.DrawImage(original, new Rectangle(0, 0, temp.Width, temp.Height), 0, 0, original.Width, original.Height, GraphicsUnit.Pixel, ia);
12 g.Dispose();
13
14 return temp;
15 }