33
System.Drawing.Color drawRedColor = System.Drawing.Color.Red;
System.Windows.Media.Color mediaColor = ?drawRedColor.ToMediaColor();?
Ash Burlaczenko
  • 24,778
  • 15
  • 68
  • 99
serhio
  • 28,010
  • 62
  • 221
  • 374

2 Answers2

59

How about:

using MColor = System.Windows.Media.Color;
using DColor = System.Drawing.Color;
...

public static MColor ToMediaColor(this DColor color)
{
   return MColor.FromArgb(color.A, color.R, color.G, color.B);
}

EDIT: Fixed the 'unpacking' of the ARGB.

Ani
  • 111,048
  • 26
  • 262
  • 307
8
System.Windows.Media.Color mediaColor = System.Windows.Media.Color.FromRgb(Color.Red.R, Color.Red.G, Color.Red.B);
Kell
  • 3,252
  • 20
  • 19
  • not correct approach, I don't need to transform the *Red* color, but a color variable :) – serhio Nov 05 '10 at 10:22
  • 6
    hmmm... maybe you should extrapolate on the answer as I extrapolated on the "question" :) – Kell Nov 05 '10 at 17:34