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); } }
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); } }
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); } }
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); } }
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); } } }
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); } }
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); } }
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); } }
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); } }
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); } }
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; } } }
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); } }
internal static IntPtr GetInstance(this INativeInstance self) { if (self == null) { return(IntPtr.Zero); } return(self.Instance); }
internal static MagickRectangle CreateInstance(INativeInstance nativeInstance) { NativeMagickRectangle instance = nativeInstance as NativeMagickRectangle; if (instance == null) throw new InvalidOperationException(); return new MagickRectangle(instance); }
internal static MagickRectangle CreateInstance(INativeInstance nativeInstance) { if (nativeInstance is not NativeMagickRectangle instance) { throw new InvalidOperationException(); } return(new MagickRectangle(instance)); }
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); } }
internal static MagickRectangle CreateInstance(INativeInstance nativeInstance) { NativeMagickRectangle instance = nativeInstance as NativeMagickRectangle; if (instance == null) { throw new InvalidOperationException(); } return(new MagickRectangle(instance)); }
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)); } } }
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)); } } }
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))); } } }
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)); } } }
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); } } }
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); } } }
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); } } }
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); } } }
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); }
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); } }
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)); } } } }
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); } } } }
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 } }