Bec*_*lin 23 .net vb.net imagemagick imagemagick.net magick++
我正在尝试为ImageMagickNet类添加自定义函数.它应该使用IsSimilarImage magick
ImageMagick.NET项目中的方法,但我对是否必须通过Magick ++路由此方法感到困惑,因为.NET端可用的任何功能都源于Magick ++.
这已经很老了,但由于尚未得到答复,所以就到这里。
请注意,我没有查看过 ImageMagick 库,因此下面代码中的任何实现细节都只是一个示例。用正确的实施取代垃圾。假设它正在导出有效的 .NET 对象,那么它的工作方式如下:
' Put your extension methods or properties in a clearly labeled module file, on its own within your project
Module ImageMagickNetExtensions
' Define an extension method by using the ExtensionAttribute, and make the first argument
' for the method the type that you wish to extend. This will serve as a reference to the extended
' instance, so that you can reference other methods and properties within your extension code.
<Extension()> _
Public Function SomeExtensionFunction(ByVal imn As ImageMagickNet, ByVal filename As String) As Boolean
Return imn.IsSimilarImage(filename)
End Function
End Module
Class SomeClass
' To use your extension method within your project containing the extension module, simply
' call it on any valid instance of the type you have extended. The compiler will call your code
' whenever it sees reference to it, passing a reference to your extended instance.
Private imn As New ImageMagickNet
Private Sub DoSomething()
If imn.SomeExtensionFunction("c:\someimage.jpg") Then
...
End If
End Sub
End Class
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1082 次 |
最近记录: |