Exemplo n.º 1
0
            public IntPtr CreateList(out UIntPtr length)
            {
                IntPtr exception = IntPtr.Zero;
                IntPtr result;

                #if PLATFORM_AnyCPU
                if (NativeLibrary.Is64Bit)
                #endif
                #if PLATFORM_x64 || PLATFORM_AnyCPU
                result = NativeMethods.X64.MagickFormatInfo_CreateList(out length, out exception);
                #endif
                #if PLATFORM_AnyCPU
                else
                #endif
                #if PLATFORM_x86 || PLATFORM_AnyCPU
                result = NativeMethods.X86.MagickFormatInfo_CreateList(out length, out exception);
                #endif
                var magickException = MagickExceptionHelper.Create(exception);
                if (magickException == null)
                {
                    return(result);
                }
                if (magickException is MagickErrorException)
                {
                    if (result != IntPtr.Zero)
                    {
                        DisposeList(result, (int)length);
                    }
                    throw magickException;
                }
                RaiseWarning(magickException);
                return(result);
            }
 public IntPtr Montage(IMagickImage image, MontageSettings settings)
 {
     using (INativeInstance settingsNative = MontageSettings.CreateInstance(settings))
     {
         IntPtr exception = IntPtr.Zero;
         IntPtr result;
         #if PLATFORM_AnyCPU
         if (NativeLibrary.Is64Bit)
         #endif
         #if PLATFORM_x64 || PLATFORM_AnyCPU
         result = NativeMethods.X64.MagickImageCollection_Montage(image.GetInstance(), settingsNative.Instance, out exception);
         #endif
         #if PLATFORM_AnyCPU
         else
         #endif
         #if PLATFORM_x86 || PLATFORM_AnyCPU
         result = NativeMethods.X86.MagickImageCollection_Montage(image.GetInstance(), settingsNative.Instance, out exception);
         #endif
         var magickException = MagickExceptionHelper.Create(exception);
         if (magickException == null)
         {
             return(result);
         }
         if (magickException is MagickErrorException)
         {
             if (result != IntPtr.Zero)
             {
                 Dispose(result);
             }
             throw magickException;
         }
         RaiseWarning(magickException);
         return(result);
     }
 }
Exemplo n.º 3
0
            public static IntPtr GetFonts(out UIntPtr length)
            {
                IntPtr exception = IntPtr.Zero;
                IntPtr result;

                #if PLATFORM_AnyCPU
                if (OperatingSystem.Is64Bit)
                #endif
                #if PLATFORM_x64 || PLATFORM_AnyCPU
                result = NativeMethods.X64.Magick_GetFonts(out length, out exception);
                #endif
                #if PLATFORM_AnyCPU
                else
                #endif
                #if PLATFORM_x86 || PLATFORM_AnyCPU
                result = NativeMethods.X86.Magick_GetFonts(out length, out exception);
                #endif
                var magickException = MagickExceptionHelper.Create(exception);
                if (magickException == null)
                {
                    return(result);
                }
                if (magickException is MagickErrorException)
                {
                    if (result != IntPtr.Zero)
                    {
                        DisposeFonts(result);
                    }
                    throw magickException;
                }
                return(result);
            }
Exemplo n.º 4
0
        protected void CheckException(IntPtr exception, IntPtr result)
        {
            var magickException = MagickExceptionHelper.Create(exception);

            if (magickException == null)
            {
                return;
            }

            if (magickException is MagickErrorException)
            {
                if (result != IntPtr.Zero)
                {
                    Dispose(result);
                }
                throw magickException;
            }

            RaiseWarning(magickException);

            if (result == IntPtr.Zero)
            {
                throw new MagickErrorException("The operation returned null but did not raise an exception.");
            }
        }
Exemplo n.º 5
0
   public IntPtr ToShortArray(int x, int y, int width, int height, string mapping)
   {
       using (INativeInstance mappingNative = UTF8Marshaler.CreateInstance(mapping))
       {
           IntPtr exception = IntPtr.Zero;
           IntPtr result;
 #if ANYCPU
           if (NativeLibrary.Is64Bit)
 #endif
 #if WIN64 || ANYCPU
           result = NativeMethods.X64.PixelCollection_ToShortArray(Instance, (UIntPtr)x, (UIntPtr)y, (UIntPtr)width, (UIntPtr)height, mappingNative.Instance, out exception);
 #endif
 #if ANYCPU
           else
 #endif
 #if !WIN64 || ANYCPU
           result = NativeMethods.X86.PixelCollection_ToShortArray(Instance, (UIntPtr)x, (UIntPtr)y, (UIntPtr)width, (UIntPtr)height, mappingNative.Instance, out exception);
 #endif
           MagickException magickException = MagickExceptionHelper.Create(exception);
           if (MagickExceptionHelper.IsError(magickException))
           {
               if (result != IntPtr.Zero)
               {
                   MagickMemory.Relinquish(result);
               }
               throw magickException;
           }
           RaiseWarning(magickException);
           return(result);
       }
   }
 public IntPtr ReadBlob(MagickSettings settings, byte[] data, int offset, int length)
 {
     using (INativeInstance settingsNative = MagickSettings.CreateInstance(settings))
     {
         IntPtr exception = IntPtr.Zero;
         IntPtr result;
         #if PLATFORM_AnyCPU
         if (NativeLibrary.Is64Bit)
         #endif
         #if PLATFORM_x64 || PLATFORM_AnyCPU
         result = NativeMethods.X64.MagickImageCollection_ReadBlob(settingsNative.Instance, data, (UIntPtr)offset, (UIntPtr)length, out exception);
         #endif
         #if PLATFORM_AnyCPU
         else
         #endif
         #if PLATFORM_x86 || PLATFORM_AnyCPU
         result = NativeMethods.X86.MagickImageCollection_ReadBlob(settingsNative.Instance, data, (UIntPtr)offset, (UIntPtr)length, out exception);
         #endif
         var magickException = MagickExceptionHelper.Create(exception);
         if (magickException == null)
         {
             return(result);
         }
         if (magickException is MagickErrorException)
         {
             if (result != IntPtr.Zero)
             {
                 Dispose(result);
             }
             throw magickException;
         }
         RaiseWarning(magickException);
         return(result);
     }
 }
Exemplo n.º 7
0
 public IntPtr ToShortArray(int x, int y, int width, int height, string mapping)
 {
     using (INativeInstance mappingNative = UTF8Marshaler.CreateInstance(mapping))
     {
         IntPtr exception = IntPtr.Zero;
         IntPtr result;
         #if PLATFORM_AnyCPU
         if (OperatingSystem.Is64Bit)
         #endif
         #if PLATFORM_x64 || PLATFORM_AnyCPU
         result = NativeMethods.X64.PixelCollection_ToShortArray(Instance, (UIntPtr)x, (UIntPtr)y, (UIntPtr)width, (UIntPtr)height, mappingNative.Instance, out exception);
         #endif
         #if PLATFORM_AnyCPU
         else
         #endif
         #if PLATFORM_x86 || PLATFORM_AnyCPU
         result = NativeMethods.X86.PixelCollection_ToShortArray(Instance, (UIntPtr)x, (UIntPtr)y, (UIntPtr)width, (UIntPtr)height, mappingNative.Instance, out exception);
         #endif
         var magickException = MagickExceptionHelper.Create(exception);
         if (magickException == null)
         {
             return(result);
         }
         if (magickException is MagickErrorException)
         {
             if (result != IntPtr.Zero)
             {
                 MagickMemory.Relinquish(result);
             }
             throw magickException;
         }
         RaiseWarning(magickException);
         return(result);
     }
 }
Exemplo n.º 8
0
            public static IntPtr GetFontFamilies(out UIntPtr length)
            {
                IntPtr exception = IntPtr.Zero;
                IntPtr result;

                #if PLATFORM_AnyCPU
                if (NativeLibrary.Is64Bit)
                #endif
                #if PLATFORM_x64 || PLATFORM_AnyCPU
                result = NativeMethods.X64.MagickNET_GetFontFamilies(out length, out exception);
                #endif
                #if PLATFORM_AnyCPU
                else
                #endif
                #if PLATFORM_x86 || PLATFORM_AnyCPU
                result = NativeMethods.X86.MagickNET_GetFontFamilies(out length, out exception);
                #endif
                MagickException magickException = MagickExceptionHelper.Create(exception);
                if (MagickExceptionHelper.IsError(magickException))
                {
                    if (result != IntPtr.Zero)
                    {
                        DisposeFontFamilies(result);
                    }
                    throw magickException;
                }
                return(result);
            }
Exemplo n.º 9
0
            public IntPtr Smush(IMagickImage?image, int offset, bool stack)
            {
                IntPtr exception = IntPtr.Zero;
                IntPtr result;

                #if PLATFORM_AnyCPU
                if (OperatingSystem.Is64Bit)
                #endif
                #if PLATFORM_x64 || PLATFORM_AnyCPU
                result = NativeMethods.X64.MagickImageCollection_Smush(image.GetInstance(), (IntPtr)offset, stack, out exception);
                #endif
                #if PLATFORM_AnyCPU
                else
                #endif
                #if PLATFORM_x86 || PLATFORM_AnyCPU
                result = NativeMethods.X86.MagickImageCollection_Smush(image.GetInstance(), (IntPtr)offset, stack, out exception);
                #endif
                var magickException = MagickExceptionHelper.Create(exception);
                if (magickException == null)
                {
                    return(result);
                }
                if (magickException is MagickErrorException)
                {
                    if (result != IntPtr.Zero)
                    {
                        Dispose(result);
                    }
                    throw magickException;
                }
                RaiseWarning(magickException);
                return(result);
            }
Exemplo n.º 10
0
 public IntPtr ReadFile(IMagickSettings <QuantumType>?settings)
 {
     using (var settingsNative = MagickSettings.CreateInstance(settings))
     {
         IntPtr exception = IntPtr.Zero;
         IntPtr result;
         #if PLATFORM_AnyCPU
         if (OperatingSystem.Is64Bit)
         #endif
         #if PLATFORM_x64 || PLATFORM_AnyCPU
         result = NativeMethods.X64.MagickImageCollection_ReadFile(settingsNative.Instance, out exception);
         #endif
         #if PLATFORM_AnyCPU
         else
         #endif
         #if PLATFORM_x86 || PLATFORM_AnyCPU
         result = NativeMethods.X86.MagickImageCollection_ReadFile(settingsNative.Instance, out exception);
         #endif
         var magickException = MagickExceptionHelper.Create(exception);
         if (magickException == null)
         {
             return(result);
         }
         if (magickException is MagickErrorException)
         {
             if (result != IntPtr.Zero)
             {
                 Dispose(result);
             }
             throw magickException;
         }
         RaiseWarning(magickException);
         return(result);
     }
 }
Exemplo n.º 11
0
            public IntPtr Polynomial(IMagickImage?image, double[] terms, int length)
            {
                IntPtr exception = IntPtr.Zero;
                IntPtr result;

                #if PLATFORM_AnyCPU
                if (OperatingSystem.Is64Bit)
                #endif
                #if PLATFORM_x64 || PLATFORM_AnyCPU
                result = NativeMethods.X64.MagickImageCollection_Polynomial(image.GetInstance(), terms, (UIntPtr)length, out exception);
                #endif
                #if PLATFORM_AnyCPU
                else
                #endif
                #if PLATFORM_x86 || PLATFORM_AnyCPU
                result = NativeMethods.X86.MagickImageCollection_Polynomial(image.GetInstance(), terms, (UIntPtr)length, out exception);
                #endif
                var magickException = MagickExceptionHelper.Create(exception);
                if (magickException == null)
                {
                    return(result);
                }
                if (magickException is MagickErrorException)
                {
                    if (result != IntPtr.Zero)
                    {
                        Dispose(result);
                    }
                    throw magickException;
                }
                RaiseWarning(magickException);
                return(result);
            }
Exemplo n.º 12
0
            public IntPtr OptimizePlus(IMagickImage image)
            {
                IntPtr exception = IntPtr.Zero;
                IntPtr result;

                #if PLATFORM_AnyCPU
                if (NativeLibrary.Is64Bit)
                #endif
                #if PLATFORM_x64 || PLATFORM_AnyCPU
                result = NativeMethods.X64.MagickImageCollection_OptimizePlus(image.GetInstance(), out exception);
                #endif
                #if PLATFORM_AnyCPU
                else
                #endif
                #if PLATFORM_x86 || PLATFORM_AnyCPU
                result = NativeMethods.X86.MagickImageCollection_OptimizePlus(image.GetInstance(), out exception);
                #endif
                var magickException = MagickExceptionHelper.Create(exception);
                if (magickException == null)
                {
                    return(result);
                }
                if (magickException is MagickErrorException)
                {
                    if (result != IntPtr.Zero)
                    {
                        Dispose(result);
                    }
                    throw magickException;
                }
                RaiseWarning(magickException);
                return(result);
            }
Exemplo n.º 13
0
 public IntPtr ReadStream(MagickSettings settings, ReadWriteStreamDelegate reader, SeekStreamDelegate seeker, TellStreamDelegate teller)
 {
     using (INativeInstance settingsNative = MagickSettings.CreateInstance(settings))
     {
         IntPtr exception = IntPtr.Zero;
         IntPtr result;
         #if PLATFORM_AnyCPU
         if (NativeLibrary.Is64Bit)
         #endif
         #if PLATFORM_x64 || PLATFORM_AnyCPU
         result = NativeMethods.X64.MagickImageCollection_ReadStream(settingsNative.Instance, reader, seeker, teller, out exception);
         #endif
         #if PLATFORM_AnyCPU
         else
         #endif
         #if PLATFORM_x86 || PLATFORM_AnyCPU
         result = NativeMethods.X86.MagickImageCollection_ReadStream(settingsNative.Instance, reader, seeker, teller, out exception);
         #endif
         var magickException = MagickExceptionHelper.Create(exception);
         if (magickException == null)
         {
             return(result);
         }
         if (magickException is MagickErrorException)
         {
             if (result != IntPtr.Zero)
             {
                 Dispose(result);
             }
             throw magickException;
         }
         RaiseWarning(magickException);
         return(result);
     }
 }
Exemplo n.º 14
0
            public IntPtr CreateList(out UIntPtr length)
            {
                IntPtr exception = IntPtr.Zero;
                IntPtr result;

        #if ANYCPU
                if (NativeLibrary.Is64Bit)
        #endif
        #if WIN64 || ANYCPU
                result = NativeMethods.X64.MagickFormatInfo_CreateList(out length, out exception);
        #endif
        #if ANYCPU
                else
        #endif
        #if !WIN64 || ANYCPU
                result = NativeMethods.X86.MagickFormatInfo_CreateList(out length, out exception);
        #endif
                MagickException magickException = MagickExceptionHelper.Create(exception);
                if (MagickExceptionHelper.IsError(magickException))
                {
                    if (result != IntPtr.Zero)
                    {
                        DisposeList(result, (int)length);
                    }
                    throw magickException;
                }
                RaiseWarning(magickException);
                return(result);
            }
Exemplo n.º 15
0
        protected void CheckException(IntPtr exception, IntPtr result)
        {
            MagickException magickException = MagickExceptionHelper.Create(exception);

            if (MagickExceptionHelper.IsError(magickException))
            {
                if (result != IntPtr.Zero)
                {
                    Dispose(result);
                }
                throw magickException;
            }

            RaiseWarning(magickException);
        }
Exemplo n.º 16
0
            public static bool SetUseOpenCL(bool value)
            {
                IntPtr exception = IntPtr.Zero;
                bool   result;

                if (NativeLibrary.Is64Bit)
                {
                    result = NativeMethods.X64.MagickNET_SetUseOpenCL(value, out exception);
                }
                else
                {
                    result = NativeMethods.X86.MagickNET_SetUseOpenCL(value, out exception);
                }
                MagickExceptionHelper.Check(exception);
                return(result);
            }
Exemplo n.º 17
0
 public static void SetDefaultFontFile(string fileName)
 {
     using (INativeInstance fileNameNative = UTF8Marshaler.CreateInstance(fileName))
     {
         IntPtr exception = IntPtr.Zero;
         #if PLATFORM_AnyCPU
         if (OperatingSystem.Is64Bit)
         #endif
         #if PLATFORM_x64 || PLATFORM_AnyCPU
         NativeMethods.X64.Magick_SetDefaultFontFile(fileNameNative.Instance, out exception);
         #endif
         #if PLATFORM_AnyCPU
         else
         #endif
         #if PLATFORM_x86 || PLATFORM_AnyCPU
         NativeMethods.X86.Magick_SetDefaultFontFile(fileNameNative.Instance, out exception);
         #endif
         MagickExceptionHelper.Check(exception);
     }
 }
Exemplo n.º 18
0
        protected void CheckException(IntPtr exception, IntPtr result)
        {
            var magickException = MagickExceptionHelper.Create(exception);

            if (magickException == null)
            {
                return;
            }

            if (magickException is MagickErrorException)
            {
                if (result != IntPtr.Zero)
                {
                    Dispose(result);
                }
                throw magickException;
            }

            RaiseWarning(magickException);
        }
Exemplo n.º 19
0
        protected void CheckException(IntPtr exception)
        {
            MagickException magickException = MagickExceptionHelper.Check(exception);

            RaiseWarning(magickException);
        }