Ejemplo n.º 1
0
 public IntPtr ReadFile(IMagickSettings <QuantumType> settings)
 {
     using (INativeInstance 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);
     }
 }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
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 (NativeLibrary.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
         MagickException magickException = MagickExceptionHelper.Create(exception);
         if (MagickExceptionHelper.IsError(magickException))
         {
             if (result != IntPtr.Zero)
             {
                 MagickMemory.Relinquish(result);
             }
             throw magickException;
         }
         RaiseWarning(magickException);
         return(result);
     }
 }
Ejemplo n.º 4
0
 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);
     }
 }
Ejemplo n.º 5
0
 public int PageCount(string fileName, string password)
 {
     using (INativeInstance fileNameNative = UTF8Marshaler.CreateInstance(fileName))
     {
         using (INativeInstance passwordNative = UTF8Marshaler.CreateInstance(password))
         {
             IntPtr  exception = IntPtr.Zero;
             UIntPtr result;
             #if PLATFORM_AnyCPU
             if (OperatingSystem.Is64Bit)
             #endif
             #if PLATFORM_x64 || PLATFORM_AnyCPU
             result = NativeMethods.X64.PdfInfo_PageCount(fileNameNative.Instance, passwordNative.Instance, out exception);
             #endif
             #if PLATFORM_AnyCPU
             else
             #endif
             #if PLATFORM_x86 || PLATFORM_AnyCPU
             result = NativeMethods.X86.PdfInfo_PageCount(fileNameNative.Instance, passwordNative.Instance, out exception);
             #endif
             CheckException(exception);
             return((int)result);
         }
     }
 }
Ejemplo n.º 6
0
 public IntPtr ReadFile(MagickSettings settings)
 {
     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_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
         MagickException magickException = MagickExceptionHelper.Create(exception);
         if (MagickExceptionHelper.IsError(magickException))
         {
             if (result != IntPtr.Zero)
             {
                 Dispose(result);
             }
             throw magickException;
         }
         RaiseWarning(magickException);
         return(result);
     }
 }
Ejemplo n.º 7
0
 public IntPtr WriteStream(IMagickImage image, MagickSettings settings, ReadWriteStreamDelegate reader, ReadWriteStreamDelegate writer, 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_WriteStream(image.GetInstance(), settingsNative.Instance, reader, writer, seeker, teller, out exception);
         #endif
         #if PLATFORM_AnyCPU
         else
         #endif
         #if PLATFORM_x86 || PLATFORM_AnyCPU
         result = NativeMethods.X86.MagickImageCollection_WriteStream(image.GetInstance(), 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);
     }
 }
Ejemplo n.º 8
0
 public IntPtr ReadBlob(MagickSettings settings, byte[] data, int length)
 {
     using (INativeInstance settingsNative = MagickSettings.CreateInstance(settings))
     {
         IntPtr exception = IntPtr.Zero;
         IntPtr result;
         if (NativeLibrary.Is64Bit)
         {
             result = NativeMethods.X64.MagickImageCollection_ReadBlob(settingsNative.Instance, data, (UIntPtr)length, out exception);
         }
         else
         {
             result = NativeMethods.X86.MagickImageCollection_ReadBlob(settingsNative.Instance, data, (UIntPtr)length, out exception);
         }
         MagickException magickException = MagickExceptionHelper.Create(exception);
         if (MagickExceptionHelper.IsError(magickException))
         {
             if (result != IntPtr.Zero)
             {
                 Dispose(result);
             }
             throw magickException;
         }
         RaiseWarning(magickException);
         return(result);
     }
 }
Ejemplo n.º 9
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);
     }
 }
Ejemplo n.º 10
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);
     }
 }
Ejemplo n.º 11
0
 public void GetInfoByName(string name)
 {
     using (INativeInstance nameNative = UTF8Marshaler.CreateInstance(name))
     {
         IntPtr exception = IntPtr.Zero;
         IntPtr result;
         #if PLATFORM_AnyCPU
         if (NativeLibrary.Is64Bit)
         #endif
         #if PLATFORM_x64 || PLATFORM_AnyCPU
         result = NativeMethods.X64.MagickFormatInfo_GetInfoByName(nameNative.Instance, out exception);
         #endif
         #if PLATFORM_AnyCPU
         else
         #endif
         #if PLATFORM_x86 || PLATFORM_AnyCPU
         result = NativeMethods.X86.MagickFormatInfo_GetInfoByName(nameNative.Instance, out exception);
         #endif
         CheckException(exception);
         if (result != IntPtr.Zero)
         {
             Instance = result;
         }
     }
 }
Ejemplo n.º 12
0
 public IntPtr ReadStream(IMagickSettings <QuantumType> 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);
     }
 }
Ejemplo n.º 13
0
 internal static IntPtr GetInstance(this INativeInstance self)
 {
     if (self == null)
     {
         return(IntPtr.Zero);
     }
     return(self.Instance);
 }
Ejemplo n.º 14
0
    internal static MagickRectangle CreateInstance(INativeInstance nativeInstance)
    {
      NativeMagickRectangle instance = nativeInstance as NativeMagickRectangle;
      if (instance == null)
        throw new InvalidOperationException();

      return new MagickRectangle(instance);
    }
Ejemplo n.º 15
0
        internal static MagickRectangle CreateInstance(INativeInstance nativeInstance)
        {
            if (nativeInstance is not NativeMagickRectangle instance)
            {
                throw new InvalidOperationException();
            }

            return(new MagickRectangle(instance));
        }
Ejemplo n.º 16
0
 public GeometryFlags Initialize(string value)
 {
   using (INativeInstance valueNative = UTF8Marshaler.CreateInstance(value))
   {
     if (NativeLibrary.Is64Bit)
       return (GeometryFlags)NativeMethods.X64.MagickGeometry_Initialize(Instance, valueNative.Instance);
     else
       return (GeometryFlags)NativeMethods.X86.MagickGeometry_Initialize(Instance, valueNative.Instance);
   }
 }
Ejemplo n.º 17
0
        internal static MagickRectangle CreateInstance(INativeInstance nativeInstance)
        {
            NativeMagickRectangle instance = nativeInstance as NativeMagickRectangle;

            if (instance == null)
            {
                throw new InvalidOperationException();
            }

            return(new MagickRectangle(instance));
        }
Ejemplo n.º 18
0
 public bool Initialize(string value)
 {
     using (INativeInstance valueNative = UTF8Marshaler.CreateInstance(value))
     {
         if (NativeLibrary.Is64Bit)
         {
             return(NativeMethods.X64.MagickColor_Initialize(Instance, valueNative.Instance));
         }
         else
         {
             return(NativeMethods.X86.MagickColor_Initialize(Instance, valueNative.Instance));
         }
     }
 }
Ejemplo n.º 19
0
 public bool FuzzyEquals(MagickColor other, QuantumType fuzz)
 {
     using (INativeInstance otherNative = MagickColor.CreateInstance(other))
     {
         if (NativeLibrary.Is64Bit)
         {
             return(NativeMethods.X64.MagickColor_FuzzyEquals(Instance, otherNative.Instance, fuzz));
         }
         else
         {
             return(NativeMethods.X86.MagickColor_FuzzyEquals(Instance, otherNative.Instance, fuzz));
         }
     }
 }
Ejemplo n.º 20
0
 public string RemoveOption(string key)
 {
     using (INativeInstance keyNative = UTF8Marshaler.CreateInstance(key))
     {
         if (NativeLibrary.Is64Bit)
         {
             return(UTF8Marshaler.NativeToManaged(NativeMethods.X64.MagickSettings_RemoveOption(Instance, keyNative.Instance)));
         }
         else
         {
             return(UTF8Marshaler.NativeToManaged(NativeMethods.X86.MagickSettings_RemoveOption(Instance, keyNative.Instance)));
         }
     }
 }
Ejemplo n.º 21
0
 public static bool Unregister(string name)
 {
     using (INativeInstance nameNative = UTF8Marshaler.CreateInstance(name))
     {
         if (NativeLibrary.Is64Bit)
         {
             return(NativeMethods.X64.MagickFormatInfo_Unregister(nameNative.Instance));
         }
         else
         {
             return(NativeMethods.X86.MagickFormatInfo_Unregister(nameNative.Instance));
         }
     }
 }
Ejemplo n.º 22
0
 public void SetTileGeometry(string value)
 {
     using (INativeInstance valueNative = UTF8Marshaler.CreateInstance(value))
     {
         if (NativeLibrary.Is64Bit)
         {
             NativeMethods.X64.MontageSettings_SetTileGeometry(Instance, valueNative.Instance);
         }
         else
         {
             NativeMethods.X86.MontageSettings_SetTileGeometry(Instance, valueNative.Instance);
         }
     }
 }
Ejemplo n.º 23
0
 public void SetStrokeColor(MagickColor value)
 {
     using (INativeInstance valueNative = MagickColor.CreateInstance(value))
     {
         if (NativeLibrary.Is64Bit)
         {
             NativeMethods.X64.MontageSettings_SetStrokeColor(Instance, valueNative.Instance);
         }
         else
         {
             NativeMethods.X86.MontageSettings_SetStrokeColor(Instance, valueNative.Instance);
         }
     }
 }
Ejemplo n.º 24
0
 public static void SetLogEvents(string events)
 {
     using (INativeInstance eventsNative = UTF8Marshaler.CreateInstance(events))
     {
         if (NativeLibrary.Is64Bit)
         {
             NativeMethods.X64.MagickNET_SetLogEvents(eventsNative.Instance);
         }
         else
         {
             NativeMethods.X86.MagickNET_SetLogEvents(eventsNative.Instance);
         }
     }
 }
Ejemplo n.º 25
0
 public void SetSize(string value)
 {
     using (INativeInstance valueNative = UTF8Marshaler.CreateInstance(value))
     {
         if (NativeLibrary.Is64Bit)
         {
             NativeMethods.X64.MagickSettings_SetSize(Instance, valueNative.Instance);
         }
         else
         {
             NativeMethods.X86.MagickSettings_SetSize(Instance, valueNative.Instance);
         }
     }
 }
Ejemplo n.º 26
0
 public void Map(MagickImage image, QuantizeSettings settings, MagickImage remapImage)
 {
     using (INativeInstance settingsNative = QuantizeSettings.CreateInstance(settings))
     {
         IntPtr exception = IntPtr.Zero;
         if (NativeLibrary.Is64Bit)
         {
             NativeMethods.X64.MagickImageCollection_Map(MagickImage.GetInstance(image), settingsNative.Instance, MagickImage.GetInstance(remapImage), out exception);
         }
         else
         {
             NativeMethods.X86.MagickImageCollection_Map(MagickImage.GetInstance(image), settingsNative.Instance, MagickImage.GetInstance(remapImage), out exception);
         }
         CheckException(exception);
     }
 }
        internal static IntPtr GetInstance(this IMagickImage self)
        {
            if (self == null)
            {
                return(IntPtr.Zero);
            }

            INativeInstance nativeInstance = self as INativeInstance;

            if (nativeInstance == null)
            {
                throw new NotSupportedException();
            }

            return(nativeInstance.Instance);
        }
Ejemplo n.º 28
0
 public void WriteFile(MagickImage image, MagickSettings settings)
 {
     using (INativeInstance settingsNative = MagickSettings.CreateInstance(settings))
     {
         IntPtr exception = IntPtr.Zero;
         if (NativeLibrary.Is64Bit)
         {
             NativeMethods.X64.MagickImageCollection_WriteFile(MagickImage.GetInstance(image), settingsNative.Instance, out exception);
         }
         else
         {
             NativeMethods.X86.MagickImageCollection_WriteFile(MagickImage.GetInstance(image), settingsNative.Instance, out exception);
         }
         CheckException(exception);
     }
 }
Ejemplo n.º 29
0
 public static int Optimize(string input, string output, bool progressive)
 {
     using (INativeInstance inputNative = UTF8Marshaler.CreateInstance(input))
     {
         using (INativeInstance outputNative = UTF8Marshaler.CreateInstance(output))
         {
             if (NativeLibrary.Is64Bit)
             {
                 return((int)NativeMethods.X64.JpegOptimizer_Optimize(inputNative.Instance, outputNative.Instance, progressive));
             }
             else
             {
                 return((int)NativeMethods.X86.JpegOptimizer_Optimize(inputNative.Instance, outputNative.Instance, progressive));
             }
         }
     }
 }
Ejemplo n.º 30
0
 public static void SetEnv(string name, string value)
 {
     using (INativeInstance nameNative = UTF8Marshaler.CreateInstance(name))
     {
         using (INativeInstance valueNative = UTF8Marshaler.CreateInstance(value))
         {
             if (NativeLibrary.Is64Bit)
             {
                 NativeMethods.X64.Environment_SetEnv(nameNative.Instance, valueNative.Instance);
             }
             else
             {
                 NativeMethods.X86.Environment_SetEnv(nameNative.Instance, valueNative.Instance);
             }
         }
     }
 }
Ejemplo n.º 31
0
 public static void SetLogEvents(string events)
 {
     using (INativeInstance eventsNative = UTF8Marshaler.CreateInstance(events))
     {
         #if PLATFORM_AnyCPU
         if (NativeLibrary.Is64Bit)
         #endif
         #if PLATFORM_x64 || PLATFORM_AnyCPU
         NativeMethods.X64.Magick_SetLogEvents(eventsNative.Instance);
         #endif
         #if PLATFORM_AnyCPU
         else
         #endif
         #if PLATFORM_x86 || PLATFORM_AnyCPU
         NativeMethods.X86.Magick_SetLogEvents(eventsNative.Instance);
         #endif
     }
 }