Is there a simple way to convert a System.Drawing.Pen into its unmanaged counterpart? Like, if you had a Pen like this:
Pen p = new Pen(Color.Blue, 1f);
IntPtr ptr = p.ToPtr();
I know this code doesn’t work, but is there a way to do it similarly?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
Penclass has an internal propertyNativePenwhich contains exactly what you want. You can access this property through reflection (if your code has the appropriate permissions) using:Be aware that theoretically this might not work in future versions of the .NET-Framework, since internal properties could change …