Why CGImageDestination can’t save CGImage?

Yauheni Pakala
Jul 10, 2020

--

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

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Yauheni Pakala
Yauheni Pakala

Written by Yauheni Pakala

I’m a software engineer. I’m a fan of technology, cross-platform development, and programming.

No responses yet

Write a response