Beispiel #1
0
 /// <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.Direct3D11.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;
         D3DX11.GetImageInfoFromFile(fileName, IntPtr.Zero, ref info, out hresult);
         return info;
     }
     catch (SharpDXException)
     { }
     return null;
 }
Beispiel #2
0
 /// <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.Direct3D11.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])
                 D3DX11.GetImageInfoFromMemory((IntPtr)pMemory, memory.Length, IntPtr.Zero, ref info, out hresult);
             // TODO test hResult?
             return info;
         }
         catch (SharpDXException)
         {
         }
         return null;
     }
 }