internal CGBitmapContext GetRenderableContext()
{
if (cachedContext != null && cachedContext.Handle != IntPtr.Zero)
return cachedContext;
var format = GetBestSupportedFormat (pixelFormat);
var bitmapContext = CreateCompatibleBitmapContext ((int)NativeCGImage.Width, (int)NativeCGImage.Height, format);
bitmapContext.DrawImage (new CGRect (0, 0, NativeCGImage.Width, NativeCGImage.Height), NativeCGImage);
int size = (int)(bitmapContext.BytesPerRow * bitmapContext.Height);
var provider = new CGDataProvider (bitmapContext.Data, size, true);
CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB();
NativeCGImage = new CGImage ((int)bitmapContext.Width, (int)bitmapContext.Height, (int)bitmapContext.BitsPerComponent,
(int)bitmapContext.BitsPerPixel, (int)bitmapContext.BytesPerRow,
colorSpace,
bitmapContext.AlphaInfo,
provider, null, true, CGColorRenderingIntent.Default);
colorSpace.Dispose ();
cachedContext = bitmapContext;
return cachedContext;
}