Xamarin-macios: Missing CGImage.Cropping method

Created on 13 Dec 2019  路  5Comments  路  Source: xamarin/xamarin-macios

  1. Trying to convert this example from stack overflow, I tried to use CGImage.Cropping in an iOS project:

C# var httpClient = new HttpClient(); var buf = await httpClient.GetByteArrayAsync("https://upload.wikimedia.org/wikipedia/commons/e/e9/Soy-whey-protein-diet.jpg"); UIImage source = UIImage.LoadFromData(NSData.FromArray(buf)); var cropRect = new CGRect(0, 0, 100, 100); var cropped = source.CGImage.Cropping(cropRect);

Expected Behavior

Compiles

Actual Behavior

Does not compile because the CGImage.Cropping method is not exposed to C#

Most helpful comment

Depending on your setting while reading doc you might be seeing the swift name cropping(to:), which is better. Most of our bindings predates those new names, so you'll have a better chance searching our docs with the C (or ObjC) API names.

All 5 comments

I found it is available as WithImageInRect.

@spouliot Should this be documented?

It mirrors the native method: CGImageCreateWithImageInRect

We are looking at improving our cross referencing with the native API, but a static "WithFoo" to map to methods like this is not uncommon.

Depending on your setting while reading doc you might be seeing the swift name cropping(to:), which is better. Most of our bindings predates those new names, so you'll have a better chance searching our docs with the C (or ObjC) API names.

@spouliot @chamons Makes sense thanks. If I find something not mapped going forward I'll switch from Swift to Objective C in the Apple doc, and know I'll likely find the Xamarin mapping there.

Was this page helpful?
0 / 5 - 0 ratings