Domanda

Sto cercando di aggiungere una funzione personalizzata in classe ImageMagickNet. Esso dovrebbe utilizzare il metodo IsSimilarImage magick dal progetto ImageMagick.NET ma sono confuso come se devo percorso questo metodo attraverso il Magick ++, come qualsiasi funzionalità a disposizione del lato .NET ha origine nel Magick ++.

Nessuna soluzione corretta

Altri suggerimenti

Questo è piuttosto vecchio, ma come è esso senza risposta, qui va.

Si prega di notare che non ho guardato le librerie ImageMagick, in modo che qualsiasi dettagli di implementazione del codice qui sotto è rigorosamente un esempio. Sostituire rifiuti con la corretta attuazione. Supponendo che sta esportando oggetti .NET validi, questo è come dovrebbe funzionare:

' 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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top