private static ColorBlend ToGDIMirrorColorBlend(this UGGradientStop[] ugStops) { var count = ugStops.Length; bool addStart = false, addEnd = false; if (ugStops[count - 1].Offset > EPSILON) { addStart = true; addEnd = true; } var outCount = 2 * count; if (addStart) { ++outCount; } if (addEnd) { ++outCount; } var gdiStops = new ColorBlend(outCount); var outIdx = 0; if (addStart) { ugStops[0].AddColorblend(ref gdiStops, ref outIdx, 0F); } ugStops.AddColorBlendRev(ref gdiStops, ref outIdx, .5F); ugStops.AddColorBlend(ref gdiStops, ref outIdx, .5F, .5F); if (addEnd) { ugStops[count - 1].AddColorblend(ref gdiStops, ref outIdx, 1F); } return(gdiStops); }