void PathGradientBrush::SetSurroundColors(Color* colors, unsigned int colorCount) {
    Gdiplus::PathGradientBrush* gdiBrush = dynamic_cast<Gdiplus::PathGradientBrush*>(reinterpret_cast<Gdiplus::Brush*>(_private));
    Gdiplus::Color* gdiColors = new Gdiplus::Color[colorCount];
    for(unsigned int a=0; a<colorCount; a++) {
        ToGDIColor(colors[a], gdiColors[a]);
    }
    int count = colorCount;
    gdiBrush->SetSurroundColors(gdiColors, &count);
    delete[] gdiColors;
}
//-----------------------------------------------------------------------------
void GdiplusDrawContext::fillRadialGradient (CGraphicsPath* _path, const CGradient& gradient, const CPoint& center, CCoord radius, const CPoint& originOffset, bool evenOdd, CGraphicsTransform* t)
{
#if DEBUG
	DebugPrint ("WARNING: GdiplusDrawContext::fillRadialGradient is not working as expected ! FIXME\n");
#endif
	GdiplusGraphicsPath* gdiPlusPath = dynamic_cast<GdiplusGraphicsPath*> (_path);
	if (gdiPlusPath && pGraphics)
	{
		GdiplusDrawScope drawScope (pGraphics, currentState.clipRect, getCurrentTransform ());

		Gdiplus::GraphicsPath* path = gdiPlusPath->getGraphicsPath ();

		if (t)
		{
			Gdiplus::Matrix matrix;
			convert (matrix, *t);
			path = path->Clone ();
			path->Transform (&matrix);
		}

		path->SetFillMode (evenOdd ? Gdiplus::FillModeAlternate : Gdiplus::FillModeWinding);
		Gdiplus::PointF c1p ((Gdiplus::REAL)(center.x + originOffset.x), (Gdiplus::REAL)(center.y + originOffset.y));

		CRect boundingBox = gdiPlusPath->getBoundingBox ();
		Gdiplus::GraphicsPath brushPath;
		brushPath.AddEllipse ((Gdiplus::REAL)boundingBox.left, (Gdiplus::REAL)boundingBox.top, (Gdiplus::REAL)boundingBox.getWidth (), (Gdiplus::REAL)boundingBox.getHeight ());
		Gdiplus::Matrix graphicsMatrix;
		pGraphics->GetTransform (&graphicsMatrix);
		brushPath.Transform (&graphicsMatrix);

		Gdiplus::PathGradientBrush brush (&brushPath);
		// set center
		brush.SetCenterPoint (c1p);
		// set the colors
		Gdiplus::Color* colors = new Gdiplus::Color [gradient.getColorStops ().size ()];
		Gdiplus::REAL* positions = new Gdiplus::REAL [gradient.getColorStops ().size ()];
		uint32_t index = 0;
		for (CGradient::ColorStopMap::const_iterator it = gradient.getColorStops ().begin (); it != gradient.getColorStops ().end (); ++it, ++index)
		{
			CColor color = it->second;
			color.alpha = (int8_t)((float)color.alpha * currentState.globalAlpha);
			colors[index] = createGdiPlusColor (color);
			positions[index] = (Gdiplus::REAL)it->first;
		}
		brush.SetCenterColor (colors[0]);
		INT count = static_cast<INT> (gradient.getColorStops ().size ()) - 1;
		brush.SetSurroundColors (colors+1, &count);

		pGraphics->FillPath (&brush, path);
		if (path != gdiPlusPath->getGraphicsPath ())
			delete path;
		delete [] colors;
		delete [] positions;
	}
}