[Mono-osx] [MonoMac] NSImage to CGImage

kjpou kjpou at pt.lu
Tue Dec 14 04:05:15 EST 2010


Hello all

The NSImage to CGImage works but the method signature needs to be 
changed as per the documentation.

All input parameters are optional. They provide hints for how to choose 
among existing CGImages, or how to create one if there isn't already a 
CGImage available. The parameters are only hints.

This method is typically called, not overridden.
Availability

     * Available in Mac OS X v10.6 and later.


--------------------------------------------------------------------------------

Here is the new signature CGImageForProposedRect:

         [Export ("CGImageForProposedRect:context:hints:")]
         CGImage CGImageForProposedRect (RectangleF proposedDestRect, 
[NullAllowed] NSGraphicsContext referenceContext, [NullAllowed] 
NSDictionary hints);

------------------------------------------------
How to use:
------------------------------------------------

             string filePath = 
NSBundle.MainBundle.PathForResource("clock-gloss","png");
             var image = new NSImage(filePath);
             var glossyImage = 
image.CGImageForProposedRect(RectangleF.Empty,null,null);

Actually it would be nice to have a helper method where you could just 
call the method with no parameters :

image.CGImageForProposedRect();

But hey it works.

Kenneth




More information about the Mono-osx mailing list