protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { _library.Dispose(); _library = null; } _disposed = true; } }
/// <summary> /// Initializes a new instance of the Ghostscript.NET.GhostscriptLibrary class /// from the GhostscriptVersionInfo object. /// </summary> /// <param name="version">GhostscriptVersionInfo instance that tells which Ghostscript library to use.</param> /// <param name="fromMemory">Tells if the Ghostscript should be loaded from the memory or directly from the disk.</param> public PdfiumLibrary() { _loadedFromMemory = true; // load native Ghostscript library into the memory byte[] buffer = File.ReadAllBytes("pdfium.dll"); // create DynamicNativeLibrary instance from the memory buffer _library = new DynamicNativeLibrary(buffer); // get and map native library symbols this.Initialize(); }
/// <summary> /// Loads Ghostscript library from the GhostscriptVersionInfo object with ability to load it from the memory and not from the disk. /// </summary> /// <param name="version">GhostscriptVersionInfo object.</param> /// <param name="fromMemory"></param> public GhostscriptLibrary(GhostscriptVersionInfo version, bool fromMemory) { _version = version; _loadedFromMemory = fromMemory; if (fromMemory) { _library = new DynamicNativeLibrary(File.ReadAllBytes(version.DllPath)); } else { _library = new DynamicNativeLibrary(version.DllPath); } this.Initialize(); }
/// <summary> /// Initializes a new instance of the Ghostscript.NET.GhostscriptLibrary class /// from the GhostscriptVersionInfo object. /// </summary> /// <param name="version">GhostscriptVersionInfo instance that tells which Ghostscript library to use.</param> /// <param name="fromMemory">Tells if the Ghostscript should be loaded from the memory or directly from the disk.</param> public GhostscriptLibrary(GhostscriptVersionInfo version, bool fromMemory) { // check if Ghostscript version is specified if (version == null) { throw new ArgumentNullException("version"); } // check if specified Ghostscript native library exist on the disk if (!File.Exists(version.DllPath)) { throw new DllNotFoundException("Ghostscript native library could not be found."); } _version = version; _loadedFromMemory = fromMemory; // check if library is compatibile with a running process if (Environment.Is64BitProcess != NativeLibraryHelper.Is64BitLibrary(version.DllPath)) { // throw friendly gsdll incompatibility message this.ThrowIncompatibileNativeGhostscriptLibraryException(); } // check wether we need to load Ghostscript native library from the memory or a disk if (fromMemory) { // load native Ghostscript library into the memory byte[] buffer = File.ReadAllBytes(version.DllPath); // create DynamicNativeLibrary instance from the memory buffer _library = new DynamicNativeLibrary(buffer); } else { // create DynamicNativeLibrary instance from the local disk file _library = new DynamicNativeLibrary(version.DllPath); } // get and map native library symbols this.Initialize(); }
/// <summary> /// Initializes a new instance of the Ghostscript.NET.GhostscriptLibrary class /// from the native library represented as the memory buffer. /// </summary> /// <param name="library">Memory buffer representing native Ghostscript library.</param> public GhostscriptLibrary(byte[] library) { if (library == null) { throw new ArgumentNullException("library"); } // check if library is compatibile with a running process if (Environment.Is64BitProcess != NativeLibraryHelper.Is64BitLibrary(library)) { // throw friendly gsdll incompatibility message this.ThrowIncompatibileNativeGhostscriptLibraryException(); } // create DynamicNativeLibrary instance from the memory buffer _library = new DynamicNativeLibrary(library); // set the flag that the library is loaded from the memory _loadedFromMemory = true; // get and map native library symbols this.Initialize(); }
public bassAudioCore() { for (var i = 0; i < _lastPeak.Length; i++) { _lastPeak[i] = 0f; } memDll = new DynamicNativeLibrary(Assembly.GetExecutingAssembly().FindEmbedded("bass.dll")); InitBass = (BASS_Init)memDll.GetDelegateForFunction("BASS_Init", typeof(BASS_Init)); if (InitBass(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero, IntPtr.Zero)) { BassFree = (BASS_Free)memDll.GetDelegateForFunction("BASS_Free", typeof(BASS_Free)); ChannelPause = (BASS_ChannelPause)memDll.GetDelegateForFunction("BASS_ChannelPause", typeof(BASS_ChannelPause)); ChannelStop = (BASS_ChannelStop)memDll.GetDelegateForFunction("BASS_ChannelStop", typeof(BASS_ChannelStop)); ChannelPlay = (BASS_ChannelPlay)memDll.GetDelegateForFunction("BASS_ChannelPlay", typeof(BASS_ChannelPlay)); MusicLoadMemory = (BASS_MusicLoad)memDll.GetDelegateForFunction("BASS_MusicLoad", typeof(BASS_MusicLoad)); GetData = (BASS_ChannelGetData)memDll.GetDelegateForFunction("BASS_ChannelGetData", typeof(BASS_ChannelGetData)); GetData2 = (BASS_ChannelGetData2)memDll.GetDelegateForFunction("BASS_ChannelGetData", typeof(BASS_ChannelGetData2)); GetData3 = (BASS_ChannelGetData3)memDll.GetDelegateForFunction("BASS_ChannelGetData", typeof(BASS_ChannelGetData3)); GetData4 = (BASS_ChannelGetData4)memDll.GetDelegateForFunction("BASS_ChannelGetData", typeof(BASS_ChannelGetData4)); GetInfo = (BASS_ChannelGetInfo)memDll.GetDelegateForFunction("BASS_ChannelGetInfo", typeof(BASS_ChannelGetInfo)); GetChanLength = (BASS_ChannelGetLength)memDll.GetDelegateForFunction("BASS_ChannelGetLength", typeof(BASS_ChannelGetLength)); GetSeconds2Bytes = (BASS_ChannelSeconds2Bytes)memDll.GetDelegateForFunction("BASS_ChannelSeconds2Bytes", typeof(BASS_ChannelSeconds2Bytes)); SetConfig = (BASS_SetConfig)memDll.GetDelegateForFunction("BASS_SetConfig", typeof(BASS_SetConfig)); GetIsActive = (BASS_ChannelIsActive)memDll.GetDelegateForFunction("BASS_ChannelIsActive", typeof(BASS_ChannelIsActive)); SetChannelPos = (BASS_ChannelSetPosition)memDll.GetDelegateForFunction("BASS_ChannelSetPosition", typeof(BASS_ChannelSetPosition)); GetBytes2Seconds = (BASS_ChannelBytes2Seconds)memDll.GetDelegateForFunction("BASS_ChannelBytes2Seconds", typeof(BASS_ChannelBytes2Seconds)); StreamCreateFileMemory = (BASS_StreamCreateFile)memDll.GetDelegateForFunction("BASS_StreamCreateFile", typeof(BASS_StreamCreateFile)); StreamFreeA = (BASS_StreamFree)memDll.GetDelegateForFunction("BASS_StreamFree", typeof(BASS_StreamFree)); GetChannelLevel = (BASS_ChannelGetLevel)memDll.GetDelegateForFunction("BASS_ChannelGetLevel", typeof(BASS_ChannelGetLevel)); GetChannelTags = (BASS_ChannelGetTags)memDll.GetDelegateForFunction("BASS_ChannelGetTags", typeof(BASS_ChannelGetTags)); GetErrorCode = (BASS_ErrorCode)memDll.GetDelegateForFunction("BASS_ErrorGetCode", typeof(BASS_ErrorCode)); PluginFree = (BASS_PluginFree)memDll.GetDelegateForFunction("BASS_PluginFree", typeof(BASS_PluginFree)); PluginLoad = (BASS_PluginLoad)memDll.GetDelegateForFunction("BASS_PluginLoad", typeof(BASS_PluginLoad)); } }
/// <summary> /// Loads Ghostscript library from the memory. /// </summary> /// <param name="buffer">Byte array.</param> public GhostscriptLibrary(byte[] gsDll) { _library = new DynamicNativeLibrary(gsDll); _loadedFromMemory = true; this.Initialize(); }