// Used for debuggin purposes internal static void SaveToFile (string fileName, CGBitmapContext bitmap) { if (bitmap == null) throw new ObjectDisposedException ("cgimage"); // With MonoTouch we can use UTType from CoreMobileServices but since // MonoMac does not have that yet (or at least can not find it) I will // use the string version of those for now. I did not want to add another // #if #else in here. // for now we will just default this to png var typeIdentifier = "public.png"; // * NOTE * we only support one image for right now. //NSMutableData imgData = new NSMutableData(); NSUrl url = NSUrl.FromFilename (fileName); // Create an image destination that saves into the imgData CGImageDestination dest = CGImageDestination.Create (url, typeIdentifier, 1); // Add an image to the destination dest.AddImage(bitmap.GetImage(), (NSDictionary)null); // Finish the export bool success = dest.Close (); // if (success == false) // Console.WriteLine("did not work"); // else // Console.WriteLine("did work: " + path); dest.Dispose(); dest = null; }