المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : GDI+ P/Invoke



C# Programming
03-07-2010, 02:30 AM
Hello. I have searched for a way to P/Invoke the Graphics.FillPolygon(Brush, Point[]) method. I saw that it is much faster to do so (likely because it bypasses error checking that is unneeded in a well-made program). However, I have not found any examples of how to do so (even .NET Reflector is of no help, only referring me to a P/Invoke that uses a private native field). Please help me translate this code into a P/Invoke. The FillPolygon method is the most important by far, as it is called 10 times more often in the real code as the Clear method is. This Render method takes up an average of 75% of the time in the code, as profiled by NProf (a specially modified version that samples 5x as often as usual was used).

public static void Render(Color color, SolidBrush brush, Point[] points, Graphics graphics)
{
graphics.Clear(color);
graphics.FillPolygon(brush, points);
}