System.Drawing.Imaging.ImageAttributes.Dispose C# (CSharp) Method

Dispose() public method

public Dispose ( ) : void
return void
		public  void Dispose()
		{
		}

Usage Example

示例#1
0
        /// <summary>
        /// Set brightness for the image
        /// </summary>
        /// <param name="image">input bitmap</param>
        /// <param name="value">value from -255 to 255</param>
        /// <returns></returns>
        public static Bitmap SetBrightness(Bitmap image, int value)
        {
            var tempBitmap  = image;
            var finalValue  = value / 255.0f;
            var newBitmap   = new Bitmap(tempBitmap.Width, tempBitmap.Height);
            var newGraphics = Graphics.FromImage(newBitmap);

            float[][] floatColorMatrix =
            {
                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, 1, 0 },
                new[]       { finalValue, finalValue, finalValue, 1, 1 }
            };

            var newColorMatrix = new System.Drawing.Imaging.ColorMatrix(floatColorMatrix);
            var attributes     = new System.Drawing.Imaging.ImageAttributes();

            attributes.SetColorMatrix(newColorMatrix);
            newGraphics.DrawImage(tempBitmap, new System.Drawing.Rectangle(0, 0, tempBitmap.Width, tempBitmap.Height), 0, 0, tempBitmap.Width, tempBitmap.Height, GraphicsUnit.Pixel, attributes);
            attributes.Dispose();
            newGraphics.Dispose();
            return(newBitmap);
        }
All Usage Examples Of System.Drawing.Imaging.ImageAttributes::Dispose