CSharp examples for System.Drawing:Color Brightness
Changes the color brightness.
// Copyright by the Spark Development Network using System.Drawing; using System;/* w ww . j av a 2s .c o m*/ public class Main{ /// <summary> /// Changes the color brightness. /// </summary> /// <param name="color">The color.</param> /// <param name="correctionFactor">The correction factor.</param> /// <returns></returns> public static Color ChangeColorBrightness( this Color color, float correctionFactor ) { float red = (float)color.R; float green = (float)color.G; float blue = (float)color.B; if ( correctionFactor < 0 ) { correctionFactor = 1 + correctionFactor; red *= correctionFactor; green *= correctionFactor; blue *= correctionFactor; } else { red = (255 - red) * correctionFactor + red; green = (255 - green) * correctionFactor + green; blue = (255 - blue) * correctionFactor + blue; } return Color.FromArgb( color.A, (int)red, (int)green, (int)blue ); } }