Pergunta

Eu estou tentando adicionar uma função personalizada para ImageMagickNet classe. Ele deve usar o método IsSimilarImage magick do projeto ImageMagick.NET mas estou confuso quanto a saber se eu tenho para encaminhar este método através do Magick ++, como qualquer funcionalidade disponível para os origina colaterais .NET no Magick ++.

Nenhuma solução correta

Outras dicas

Isso é muito antigo, mas como é sem resposta, aqui vai.

Por favor note que eu não olhei para as bibliotecas ImageMagick, portanto, quaisquer detalhes de implementação do código abaixo é estritamente um exemplo. Substitua lixo com a implementação correta. Assumindo que está exportando objetos .NET válidos, isto é como ele iria trabalhar:

' 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 em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top