I have a problem using GDI+ to draw a polygon which has a inner ring, I'm expecting the result to be blank because the current screen is inside the inner ring, but I got a solid fill result; If I scale down the outer ring, I can get the correct result, can anyone explain this behavior? The code is posted below
public static void Main()
{
SaveBitmap(1);
SaveBitmap(10);
}
private static void SaveBitmap(double factor)
{
Bitmap bitmap = new Bitmap(800, 600);
GraphicsPath path = new GraphicsPath();
path.AddPolygon(GetOuterRing(factor));
path.AddPolygon(GetInnerRing());
Graphics g = Graphics.FromImage(bitmap);
g.FillPath(new SolidBrush(Color.LightBlue), path);
g.Dispose();
bitmap.Save(factor + ".jpg");
bitmap.Dispose();
}
private static PointF[] GetOuterRing(double factor)
{
return new PointF[]
{
new PointF((float)(-8388210.0f / factor), (float)(-4194020.5f/ factor)),
new PointF((float)(8389000.0f/ factor), (float)(-4194020.5f/ factor)),
new PointF((float)(8389000.0f/ factor), (float)(4194580.5f/ factor)),
new PointF((float)(-8388210.0f/ factor),(float)(4194580.5f/ factor)),
new PointF((float)(-8388210.0f/ factor), (float)(-4194020.5f/ factor))
};
}
private static PointF[] GetInnerRing()
{
return new PointF[]
{
new PointF(-419038.4f, -209434.7f),
new PointF(-419038.4f, 209995.7f),
new PointF(419822.4f, 209995.7f),
new PointF(419822.4f, -209434.7f),
new PointF(-419038.4f, -209434.7f),
};
}