DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Set Image Opacity
public static Image SetOpacity(Image original, float opacity)
{
Bitmap temp = new Bitmap(original.Width, original.Height);
Graphics g = Graphics.FromImage(temp);
ColorMatrix cm = new ColorMatrix();
cm.Matrix33 = opacity;
ImageAttributes ia = new ImageAttributes();
ia.SetColorMatrix(cm, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
g.DrawImage(original, new Rectangle(0, 0, temp.Width, temp.Height), 0, 0, original.Width, original.Height, GraphicsUnit.Pixel, ia);
g.Dispose();
return temp;
}




