Pregunta

Estoy tratando de agregar una función personalizada para ImageMagickNet clase. Se debe utilizar el método IsSimilarImage magick del proyecto ImageMagick.NET pero estoy confundido en cuanto a si tengo que este método ruta a través de la magia ++, como cualquier funcionalidad disponible para el lado .NET se origina en el Magick ++.

No hay solución correcta

Otros consejos

Esto es bastante viejo, pero como lo es sin respuesta, aquí va.

Tenga en cuenta que no he mirado las bibliotecas de ImageMagick, por lo que cualquier detalles de implementación en el código de abajo es estrictamente un ejemplo. Reemplazar la basura con la aplicación correcta. Si se asume que es la exportación de objetos .NET válidos, esto es cómo funcionaría:

' 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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top