[Mono-osx] System.Drawing into Cocoa views?

Eric J. M. Smith eric at tarkvara.org
Wed Jul 20 13:15:43 EDT 2011

Hi everybody,

Clay Fowler was able to provide more information about the drawing
bridge (appended to the end of this message).  The good news is that
the functionality is already built into MonoMac using
Graphics.fromHwnd().  The bad news is that it depends on the user
having X11 installed, as well as a version of libfreetype.6.dylib
which is newer than the one included with Apple's X11.

Hope that helps,

Eric Smith
Tarkvara Design Inc.

On 18 July 2011 17:29, Clay Fowler wrote:
> Rendering in a NSView with System.Drawing is very simple and performs
> extremely well. We also have cross-platform rendering in our products. To
> use it, just enable the bridge with one line of code in the Main of your
> project:
> NSApplication.InitDrawingBridge();
> (... we do this right after NSApplication.Init() and
> before NSApplication.Main(args)).
> Then override DrawRect in your custom NSView classes and do this:
> public override void DrawRect(RectangleF rect)
> {
> if (Handle != IntPtr.Zero)
> {
> using (Graphics g = Graphics.FromHwnd (Handle))
> {
>                     // ... Normal drawing here...

More information about the Mono-osx mailing list