|
Set Image Opacity Using C#
A C# function for changing the opacity on an image to the specified value. It uses the System.Drawing, System.Drawing.Imaging and System.Drawing.Drawing2D namespaces.
|
On Wednesday, April 16th 2008 at 12:28 AM By Andrew Pociu (View Profile)
    (Rated 4.8 with 4 votes) |
Contextual Ads
More C# Resources
Advertisement
public static Image SetImgOpacity(Image imgPic, float imgOpac)
{
Bitmap bmpPic = new Bitmap (imgPic. Width, imgPic. Height);
Graphics gfxPic = Graphics.FromImage(bmpPic);
ColorMatrix cmxPic = new ColorMatrix ();
cmxPic.Matrix33 = imgOpac;
ImageAttributes iaPic = new ImageAttributes ();
iaPic.SetColorMatrix(cmxPic, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
gfxPic. DrawImage(imgPic, new Rectangle (0, 0, bmpPic. Width, bmpPic. Height), 0, 0, imgPic. Width, imgPic. Height, GraphicsUnit. Pixel, iaPic );
gfxPic.Dispose();
return bmpPic;
}
|
Digg It!
Del.icio.us
Reddit
StumbleIt
Newsvine
Furl
BlinkList
|
|
Rate this code snippet
Current Comments
|
Related Source Code
There is no related code.
Related Tutorials
There are no related tutorials.
C# Job Search
|
|
|