From 39bfa775f260a531ad7e54f3968ccf7941ea08c0 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 21 Jan 2022 10:20:08 +0100 Subject: [PATCH] [CoreImage] Strong-type a format parameter to CIContext.CreateCGImage in .NET. --- src/CoreImage/CIContext.cs | 2 ++ src/coreimage.cs | 4 ++++ tests/monotouch-test/CoreImage/CoreContextTest.cs | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/src/CoreImage/CIContext.cs b/src/CoreImage/CIContext.cs index 7be2a77a6491..c7fc3a1f10ba 100644 --- a/src/CoreImage/CIContext.cs +++ b/src/CoreImage/CIContext.cs @@ -221,10 +221,12 @@ public static CIContext FromOptions (CIContextOptions? options) return FromOptions (options?.Dictionary); } +#if !NET public CGImage? CreateCGImage (CIImage image, CGRect fromRect, CIFormat ciImageFormat, CGColorSpace? colorSpace) { return CreateCGImage (image, fromRect, CIImage.CIFormatToInt (ciImageFormat), colorSpace); } +#endif #endif } } diff --git a/src/coreimage.cs b/src/coreimage.cs index 6532d649ae5a..b4af007cf765 100644 --- a/src/coreimage.cs +++ b/src/coreimage.cs @@ -302,7 +302,11 @@ interface CIContext { [Export ("createCGImage:fromRect:format:colorSpace:")] [return: Release ()] [return: NullAllowed] +#if NET + CGImage CreateCGImage (CIImage image, CGRect fromRect, CIFormat /* CIFormat = int */ ciImageFormat, [NullAllowed] CGColorSpace colorSpace); +#else CGImage CreateCGImage (CIImage image, CGRect fromRect, int /* CIFormat = int */ ciImageFormat, [NullAllowed] CGColorSpace colorSpace); +#endif [iOS (10,0)][Mac (10,12)] [TV (10,0)] diff --git a/tests/monotouch-test/CoreImage/CoreContextTest.cs b/tests/monotouch-test/CoreImage/CoreContextTest.cs index d8a153eba7b0..06d28f7b9207 100644 --- a/tests/monotouch-test/CoreImage/CoreContextTest.cs +++ b/tests/monotouch-test/CoreImage/CoreContextTest.cs @@ -53,7 +53,11 @@ public void CreateRefCount () Assert.AreEqual (1, rc, "CreateCGImage #a1"); } +#if NET + using (var v = ctx.CreateCGImage (img, new CGRect (0, 0, 32, 32), CIFormat.ARGB8, null)) { +#else using (var v = ctx.CreateCGImage (img, new CGRect (0, 0, 32, 32), CIImage.FormatARGB8, null)) { +#endif int rc = Messaging.int_objc_msgSend (v.Handle, retainCount.Handle); Assert.AreEqual (1, rc, "CreateCGImage #b1"); }