/// <summary> /// Loads the specified image from a file. /// </summary> /// <param name="fileName">The filename.</param> /// <returns>An new image.</returns> /// <remarks>This method support the following format: <c>dds, bmp, jpg, png, gif, tiff, wmp, tga</c>.</remarks> public static Image Load(string fileName) { NativeFileStream stream = null; IntPtr memoryPtr = IntPtr.Zero; int size; try { stream = new NativeFileStream(fileName, NativeFileMode.Open, NativeFileAccess.Read); size = (int)stream.Length; memoryPtr = Utilities.AllocateMemory(size); stream.Read(memoryPtr, 0, size); } catch (Exception) { if (memoryPtr != IntPtr.Zero) { Utilities.FreeMemory(memoryPtr); } throw; } finally { try { if (stream != null) { stream.Dispose(); } } catch {} } // If everything was fine, load the image from memory return(Load(memoryPtr, size, false)); }
/// <summary> /// Abre o arquivo de carrega para o stream. /// </summary> /// <param name="filename"></param> public EngineSound(string filename) { Stream fileStream = new NativeFileStream(filename, NativeFileMode.Open, NativeFileAccess.Read, NativeFileShare.Read); SoundStream = new SoundStream(fileStream); AudioBuffer = new AudioBuffer(SoundStream.ToDataStream()); fileStream.Dispose(); }
public static void Save(string fullPath, ShaderCollection shaderCollection) { NativeFileStream fs = new NativeFileStream(fullPath, NativeFileMode.Create, NativeFileAccess.Write); try { BinarySerializer bs = new BinarySerializer(fs, SerializerMode.Write) { AllowIdentity = true }; bs.Serialize(ref shaderCollection); } catch (SerializationException e) { LogEvent.Tool.Error(e.Message); throw; } finally { fs.Dispose(); } }
public void Dispose() { if (_xAudio2 != null) { _xAudio2.Dispose(); } if (_soundStream != null) { _soundStream.Dispose(); } if (_nativeFilestream != null) { _nativeFilestream.Dispose(); } if (_sourceVoice != null) { _sourceVoice.Dispose(); } if (_masteringVoice != null) { _masteringVoice.Dispose(); } }
public static ShaderCollection Load(string fullPath) { NativeFileStream fs = new NativeFileStream(fullPath, NativeFileMode.Open, NativeFileAccess.Read); try { ShaderCollection sc = null; BinarySerializer bs = new BinarySerializer(fs, SerializerMode.Read) { AllowIdentity = true }; bs.Serialize(ref sc); return(sc); } catch (SerializationException e) { LogEvent.Tool.Error(e.Message); throw; } finally { fs.Dispose(); } }