Why CGImageDestination can’t save CGImage?
Short solution for Xamarin.iOS
First, look at the work solution:
var fileUrl = NSUrl.FromFilename(...);
using var img = assetImageGenerator.CopyCGImageAtTime(...);//...using (var dest = CGImageDestination.Create(fileUrl, UTType.PNG, 1))
{
dest.AddImage(img);
dest.Close();
}
The manual call method Close() is important!
Look at method description:
“Writes the images to the destination and disposes the object.” — Seems so
But Dispose pattern implementation doesn’t support that. Because doesn’t call Close() method.
UPD: GitHub issue: https://github.com/xamarin/xamarin-macios/issues/9058