/// <summary> /// Retrieves information about a given image file. /// </summary> /// <param name="fileName">File name of image to retrieve information about.</param> /// <returns>If the function succeeds, returns a <see cref="SharpDX.Direct3D10.ImageInformation"/> filled with the description of the data in the source file. else returns null </returns> /// <unmanaged>HRESULT D3DX11GetImageInfoFromFileW([None] const wchar_t* pSrcFile,[None] ID3DX11ThreadPump* pPump,[None] D3DX11_IMAGE_INFO* pSrcInfo,[None] HRESULT* pHResult)</unmanaged> public static ImageInformation? FromFile(string fileName) { try { var info = new ImageInformation(); Result hresult; D3DX10.GetImageInfoFromFile(fileName, IntPtr.Zero, ref info, out hresult); // TODO check hresult? return info; } catch (SharpDXException) { } return null; }
/// <summary> /// Retrieves information about a given image file from a memory location. /// </summary> /// <param name="memory">an array to the image in memory</param> /// <returns>If the function succeeds, returns a <see cref="SharpDX.Direct3D10.ImageInformation"/> filled with the description of the data from the image memory. else returns null </returns> /// <unmanaged>HRESULT D3DX11GetImageInfoFromFileW([None] const wchar_t* pSrcFile,[None] ID3DX11ThreadPump* pPump,[None] D3DX11_IMAGE_INFO* pSrcInfo,[None] HRESULT* pHResult)</unmanaged> public static ImageInformation? FromMemory(byte[] memory) { unsafe { try { var info = new ImageInformation(); Result hresult; fixed (void* pMemory = &memory[0]) D3DX10.GetImageInfoFromMemory((IntPtr)pMemory, memory.Length, IntPtr.Zero, ref info, out hresult); // TODO check hresult? return info; } catch (SharpDXException) { } return null; } }