Never been to DZone Snippets before?

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

About this user

Miroslav Stampar http://mstampar.awardspace.com

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Set image opacity

   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          } 
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS