/// <summary> /// Loads a texture from an image in memory. /// </summary> /// <param name = "device">The device used to load the texture.</param> /// <param name = "memory">Array of memory containing the image data to load.</param> /// <returns>The loaded texture object.</returns> public static T FromMemory <T>(Device device, byte[] memory) where T : Resource { unsafe { IntPtr temp; Result resultOut; fixed(void *pBuffer = &memory[0]) D3DX10.CreateTextureFromMemory(device, (IntPtr)pBuffer, memory.Length, null, IntPtr.Zero, out temp, out resultOut); // TODO test resultOut return(FromPointer <T>(temp)); } }
/// <summary> /// Loads a texture from an image in memory. /// </summary> /// <param name = "device">The device used to load the texture.</param> /// <param name = "memory">Array of memory containing the image data to load.</param> /// <returns>The loaded texture object.</returns> public static T FromMemory <T>(Device device, byte[] memory) where T : Resource { System.Diagnostics.Debug.Assert(typeof(T) == typeof(Texture1D) || typeof(T) == typeof(Texture2D) || typeof(T) == typeof(Texture3D)); unsafe { System.Diagnostics.Debug.Assert(memory != null); System.Diagnostics.Debug.Assert(memory.Length > 0); IntPtr temp; Result resultOut; fixed(void *pBuffer = &memory[0]) D3DX10.CreateTextureFromMemory(device, (IntPtr)pBuffer, memory.Length, null, IntPtr.Zero, out temp, out resultOut); // TODO test resultOut return(FromPointer <T>(temp)); } }