CSharp examples for System.Drawing:Color Calculation
Get Intermediate Color
using System.Reflection; using System.IO;//from w w w . j a v a2s .c o m using System.Drawing.Drawing2D; using System.Drawing; using System.Text; using System.Collections.Generic; using System; public class Main{ public static Color GetIntermediateColor(Color c, Color c2, int value) { float pc = value * 1.0F / 100; int ca = c.A, cr = c.R, cg = c.G, cb = c.B; int c2a = c2.A, c2r = c2.R, c2g = c2.G, c2b = c2.B; int a = (int)Math.Abs(ca + (ca - c2a) * pc); int r = (int)Math.Abs(cr - ((cr - c2r) * pc)); int g = (int)Math.Abs(cg - ((cg - c2g) * pc)); int b = (int)Math.Abs(cb - ((cb - c2b) * pc)); if (a > 255) { a = 255; } if (r > 255) { r = 255; } if (g > 255) { g = 255; } if (b > 255) { b = 255; } return (Color.FromArgb(a, r, g, b)); } }