GetInstance() static private method

static private GetInstance ( MagickImage instance ) : IntPtr
instance MagickImage
return System.IntPtr
Beispiel #1
0
   public IntPtr WriteStream(MagickImage image, MagickSettings settings, ReadWriteStreamDelegate reader, ReadWriteStreamDelegate writer, SeekStreamDelegate seeker, TellStreamDelegate teller)
   {
       using (INativeInstance settingsNative = MagickSettings.CreateInstance(settings))
       {
           IntPtr exception = IntPtr.Zero;
           IntPtr result;
 #if ANYCPU
           if (NativeLibrary.Is64Bit)
 #endif
 #if WIN64 || ANYCPU
           result = NativeMethods.X64.MagickImageCollection_WriteStream(MagickImage.GetInstance(image), settingsNative.Instance, reader, writer, seeker, teller, out exception);
 #endif
 #if ANYCPU
           else
 #endif
 #if !WIN64 || ANYCPU
           result = NativeMethods.X86.MagickImageCollection_WriteStream(MagickImage.GetInstance(image), settingsNative.Instance, reader, writer, seeker, teller, out exception);
 #endif
           MagickException magickException = MagickExceptionHelper.Create(exception);
           if (MagickExceptionHelper.IsError(magickException))
           {
               if (result != IntPtr.Zero)
               {
                   Dispose(result);
               }
               throw magickException;
           }
           RaiseWarning(magickException);
           return(result);
       }
   }
Beispiel #2
0
            public IntPtr Smush(MagickImage image, int offset, bool stack)
            {
                IntPtr exception = IntPtr.Zero;
                IntPtr result;

                if (NativeLibrary.Is64Bit)
                {
                    result = NativeMethods.X64.MagickImageCollection_Smush(MagickImage.GetInstance(image), (IntPtr)offset, stack, out exception);
                }
                else
                {
                    result = NativeMethods.X86.MagickImageCollection_Smush(MagickImage.GetInstance(image), (IntPtr)offset, stack, out exception);
                }
                MagickException magickException = MagickExceptionHelper.Create(exception);

                if (MagickExceptionHelper.IsError(magickException))
                {
                    if (result != IntPtr.Zero)
                    {
                        Dispose(result);
                    }
                    throw magickException;
                }
                RaiseWarning(magickException);
                return(result);
            }
Beispiel #3
0
 public IntPtr WriteBlob(MagickImage image, MagickSettings settings, out UIntPtr length)
 {
     using (INativeInstance settingsNative = MagickSettings.CreateInstance(settings))
     {
         IntPtr exception = IntPtr.Zero;
         IntPtr result;
         if (NativeLibrary.Is64Bit)
         {
             result = NativeMethods.X64.MagickImageCollection_WriteBlob(MagickImage.GetInstance(image), settingsNative.Instance, out length, out exception);
         }
         else
         {
             result = NativeMethods.X86.MagickImageCollection_WriteBlob(MagickImage.GetInstance(image), settingsNative.Instance, out length, out exception);
         }
         MagickException magickException = MagickExceptionHelper.Create(exception);
         if (MagickExceptionHelper.IsError(magickException))
         {
             if (result != IntPtr.Zero)
             {
                 MagickMemory.Relinquish(result);
             }
             throw magickException;
         }
         RaiseWarning(magickException);
         return(result);
     }
 }
Beispiel #4
0
            public NativePixelCollection(IMagickImage?image)
            {
                IntPtr exception = IntPtr.Zero;

                #if PLATFORM_AnyCPU
                if (OperatingSystem.IsArm64)
                #endif
                #if PLATFORM_arm64 || PLATFORM_AnyCPU
                Instance = NativeMethods.ARM64.PixelCollection_Create(MagickImage.GetInstance(image), out exception);
                #endif
                #if PLATFORM_AnyCPU
                else if (OperatingSystem.Is64Bit)
                #endif
                #if PLATFORM_x64 || PLATFORM_AnyCPU
                Instance = NativeMethods.X64.PixelCollection_Create(MagickImage.GetInstance(image), out exception);
                #endif
                #if PLATFORM_AnyCPU
                else
                #endif
                #if PLATFORM_x86 || PLATFORM_AnyCPU
                Instance = NativeMethods.X86.PixelCollection_Create(MagickImage.GetInstance(image), out exception);
                #endif
                CheckException(exception, Instance);
                if (Instance == IntPtr.Zero)
                {
                    throw new InvalidOperationException();
                }
            }
Beispiel #5
0
            public IntPtr OptimizePlus(MagickImage image)
            {
                IntPtr exception = IntPtr.Zero;
                IntPtr result;

        #if ANYCPU
                if (NativeLibrary.Is64Bit)
        #endif
        #if WIN64 || ANYCPU
                result = NativeMethods.X64.MagickImageCollection_OptimizePlus(MagickImage.GetInstance(image), out exception);
        #endif
        #if ANYCPU
                else
        #endif
        #if !WIN64 || ANYCPU
                result = NativeMethods.X86.MagickImageCollection_OptimizePlus(MagickImage.GetInstance(image), out exception);
        #endif
                MagickException magickException = MagickExceptionHelper.Create(exception);
                if (MagickExceptionHelper.IsError(magickException))
                {
                    if (result != IntPtr.Zero)
                    {
                        Dispose(result);
                    }
                    throw magickException;
                }
                RaiseWarning(magickException);
                return(result);
            }
Beispiel #6
0
 public IntPtr Montage(MagickImage image, MontageSettings settings)
 {
     using (INativeInstance settingsNative = MontageSettings.CreateInstance(settings))
     {
         IntPtr exception = IntPtr.Zero;
         IntPtr result;
         if (NativeLibrary.Is64Bit)
         {
             result = NativeMethods.X64.MagickImageCollection_Montage(MagickImage.GetInstance(image), settingsNative.Instance, out exception);
         }
         else
         {
             result = NativeMethods.X86.MagickImageCollection_Montage(MagickImage.GetInstance(image), settingsNative.Instance, out exception);
         }
         MagickException magickException = MagickExceptionHelper.Create(exception);
         if (MagickExceptionHelper.IsError(magickException))
         {
             if (result != IntPtr.Zero)
             {
                 Dispose(result);
             }
             throw magickException;
         }
         RaiseWarning(magickException);
         return(result);
     }
 }
Beispiel #7
0
            public IntPtr Merge(MagickImage image, LayerMethod method)
            {
                IntPtr exception = IntPtr.Zero;
                IntPtr result;

                if (NativeLibrary.Is64Bit)
                {
                    result = NativeMethods.X64.MagickImageCollection_Merge(MagickImage.GetInstance(image), (UIntPtr)method, out exception);
                }
                else
                {
                    result = NativeMethods.X86.MagickImageCollection_Merge(MagickImage.GetInstance(image), (UIntPtr)method, out exception);
                }
                MagickException magickException = MagickExceptionHelper.Create(exception);

                if (MagickExceptionHelper.IsError(magickException))
                {
                    if (result != IntPtr.Zero)
                    {
                        Dispose(result);
                    }
                    throw magickException;
                }
                RaiseWarning(magickException);
                return(result);
            }
Beispiel #8
0
 public static IntPtr GetInstance(MagickImage image, IntPtr list, PixelChannel channel)
 {
     if (NativeLibrary.Is64Bit)
     {
         return(NativeMethods.X64.PerceptualHash_GetInstance(MagickImage.GetInstance(image), list, (UIntPtr)channel));
     }
     else
     {
         return(NativeMethods.X86.PerceptualHash_GetInstance(MagickImage.GetInstance(image), list, (UIntPtr)channel));
     }
 }
Beispiel #9
0
            public void OptimizeTransparency(MagickImage image)
            {
                IntPtr exception = IntPtr.Zero;

                if (NativeLibrary.Is64Bit)
                {
                    NativeMethods.X64.MagickImageCollection_OptimizeTransparency(MagickImage.GetInstance(image), out exception);
                }
                else
                {
                    NativeMethods.X86.MagickImageCollection_OptimizeTransparency(MagickImage.GetInstance(image), out exception);
                }
                CheckException(exception);
            }
            public void WriteFile(MagickImage image, MagickSettings settings)
            {
                IntPtr exception = IntPtr.Zero;

                if (NativeLibrary.Is64Bit)
                {
                    NativeMethods.X64.MagickImageCollection_WriteFile(MagickImage.GetInstance(image), MagickSettings.GetInstance(settings), out exception);
                }
                else
                {
                    NativeMethods.X86.MagickImageCollection_WriteFile(MagickImage.GetInstance(image), MagickSettings.GetInstance(settings), out exception);
                }
                CheckException(exception);
            }
Beispiel #11
0
     public static IntPtr GetInstance(MagickImage image, IntPtr list, PixelChannel channel)
     {
 #if ANYCPU
         if (NativeLibrary.Is64Bit)
 #endif
 #if WIN64 || ANYCPU
         return(NativeMethods.X64.PerceptualHash_GetInstance(MagickImage.GetInstance(image), list, (UIntPtr)channel));
 #endif
 #if ANYCPU
         else
 #endif
 #if !WIN64 || ANYCPU
         return(NativeMethods.X86.PerceptualHash_GetInstance(MagickImage.GetInstance(image), list, (UIntPtr)channel));
 #endif
     }
Beispiel #12
0
 public void Quantize(MagickImage image, QuantizeSettings settings)
 {
     using (INativeInstance settingsNative = QuantizeSettings.CreateInstance(settings))
     {
         IntPtr exception = IntPtr.Zero;
         if (NativeLibrary.Is64Bit)
         {
             NativeMethods.X64.MagickImageCollection_Quantize(MagickImage.GetInstance(image), settingsNative.Instance, out exception);
         }
         else
         {
             NativeMethods.X86.MagickImageCollection_Quantize(MagickImage.GetInstance(image), settingsNative.Instance, out exception);
         }
         CheckException(exception);
     }
 }
Beispiel #13
0
            public void OptimizeTransparency(MagickImage image)
            {
                IntPtr exception = IntPtr.Zero;

        #if ANYCPU
                if (NativeLibrary.Is64Bit)
        #endif
        #if WIN64 || ANYCPU
                NativeMethods.X64.MagickImageCollection_OptimizeTransparency(MagickImage.GetInstance(image), out exception);
        #endif
        #if ANYCPU
                else
        #endif
        #if !WIN64 || ANYCPU
                NativeMethods.X86.MagickImageCollection_OptimizeTransparency(MagickImage.GetInstance(image), out exception);
        #endif
                CheckException(exception);
            }
Beispiel #14
0
            public NativePixelCollection(MagickImage image)
            {
                IntPtr exception = IntPtr.Zero;

                if (NativeLibrary.Is64Bit)
                {
                    _Instance = NativeMethods.X64.PixelCollection_Create(MagickImage.GetInstance(image), out exception);
                }
                else
                {
                    _Instance = NativeMethods.X86.PixelCollection_Create(MagickImage.GetInstance(image), out exception);
                }
                CheckException(exception, _Instance);
                if (_Instance == IntPtr.Zero)
                {
                    throw new InvalidOperationException();
                }
            }
Beispiel #15
0
   public void WriteFile(MagickImage image, MagickSettings settings)
   {
       using (INativeInstance settingsNative = MagickSettings.CreateInstance(settings))
       {
           IntPtr exception = IntPtr.Zero;
 #if ANYCPU
           if (NativeLibrary.Is64Bit)
 #endif
 #if WIN64 || ANYCPU
           NativeMethods.X64.MagickImageCollection_WriteFile(MagickImage.GetInstance(image), settingsNative.Instance, out exception);
 #endif
 #if ANYCPU
           else
 #endif
 #if !WIN64 || ANYCPU
           NativeMethods.X86.MagickImageCollection_WriteFile(MagickImage.GetInstance(image), settingsNative.Instance, out exception);
 #endif
           CheckException(exception);
       }
   }
Beispiel #16
0
            public NativePixelCollection(MagickImage image)
            {
                IntPtr exception = IntPtr.Zero;

        #if ANYCPU
                if (NativeLibrary.Is64Bit)
        #endif
        #if WIN64 || ANYCPU
                Instance = NativeMethods.X64.PixelCollection_Create(MagickImage.GetInstance(image), out exception);
        #endif
        #if ANYCPU
                else
        #endif
        #if !WIN64 || ANYCPU
                Instance = NativeMethods.X86.PixelCollection_Create(MagickImage.GetInstance(image), out exception);
        #endif
                CheckException(exception, Instance);
                if (Instance == IntPtr.Zero)
                {
                    throw new InvalidOperationException();
                }
            }
Beispiel #17
0
            public static IntPtr GetInstance(IMagickImage?image, IntPtr list, PixelChannel channel)
            {
                IntPtr result;

                #if PLATFORM_AnyCPU
                if (OperatingSystem.IsArm64)
                #endif
                #if PLATFORM_arm64 || PLATFORM_AnyCPU
                result = NativeMethods.ARM64.PerceptualHash_GetInstance(MagickImage.GetInstance(image), list, (UIntPtr)channel);
                #endif
                #if PLATFORM_AnyCPU
                else if (OperatingSystem.Is64Bit)
                #endif
                #if PLATFORM_x64 || PLATFORM_AnyCPU
                result = NativeMethods.X64.PerceptualHash_GetInstance(MagickImage.GetInstance(image), list, (UIntPtr)channel);
                #endif
                #if PLATFORM_AnyCPU
                else
                #endif
                #if PLATFORM_x86 || PLATFORM_AnyCPU
                result = NativeMethods.X86.PerceptualHash_GetInstance(MagickImage.GetInstance(image), list, (UIntPtr)channel);
                #endif
                return(result);
            }