Skip to content

Commit

Permalink
[CoreImage] Strong-type a format parameter to CIContext.CreateCGImage…
Browse files Browse the repository at this point in the history
… in .NET.
  • Loading branch information
rolfbjarne committed Jan 21, 2022
1 parent aefbf49 commit 39bfa77
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/CoreImage/CIContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
4 changes: 4 additions & 0 deletions src/coreimage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 4 additions & 0 deletions tests/monotouch-test/CoreImage/CoreContextTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down

0 comments on commit 39bfa77

Please sign in to comment.