質問

私は、クラスImageMagickNetにカスタム機能を追加しようとしています。それはImageMagick.NETプロジェクトからIsSimilarImage magickメソッドを使用する必要がありますが、私は、.NET側で利用可能なすべての機能が魔術++に起因するとして、私は、魔術++経由ルートにこの方法を持っているかどうかについて混乱しています。

正しい解決策はありません

他のヒント

これはかなり古いですが、それが未回答であるとして、ここに行く。

私は以下のコードのいずれかの実装の詳細は、厳密に一例であり、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
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top