2010-02-09 15 views
23

मैं कक्षा ImageMagickNet के लिए एक कस्टम समारोह जोड़ने की कोशिश कर रहा हूँ। यह ImageMagick.NET परियोजना से IsSimilarImage magick विधि का उपयोग करना चाहिए, लेकिन मैं करने के लिए मैं रूट करने के लिए Magick ++ के माध्यम से इस पद्धति है या नहीं के रूप में उलझन में हूँ, नेट ओर करने के लिए किसी भी कार्यक्षमता के रूप में उपलब्ध Magick में निकलती ++।विस्तार ImageMagickNet

उत्तर

2

यह सुंदर पुराना है लेकिन यह अनुत्तरित, यहाँ जाता है के रूप में।

कृपया ध्यान दें कि मैं 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 
संबंधित मुद्दे