d3dx9: Implement D3DXLoadSurfaceFromFile.

This commit is contained in:
Tony Wasserka 2009-06-22 17:33:48 +02:00 committed by Alexandre Julliard
parent 818223e75e
commit 2a9c43fb35
2 changed files with 56 additions and 2 deletions

View File

@ -182,9 +182,9 @@
@ stub D3DXLoadPRTCompBufferFromFileA
@ stub D3DXLoadPRTCompBufferFromFileW
@ stub D3DXLoadSkinMeshFromXof
@ stub D3DXLoadSurfaceFromFileA
@ stdcall D3DXLoadSurfaceFromFileA(ptr ptr ptr str ptr long long ptr)
@ stdcall D3DXLoadSurfaceFromFileInMemory(ptr ptr ptr ptr long ptr long long ptr)
@ stub D3DXLoadSurfaceFromFileW
@ stdcall D3DXLoadSurfaceFromFileW(ptr ptr ptr wstr ptr long long ptr)
@ stub D3DXLoadSurfaceFromMemory
@ stub D3DXLoadSurfaceFromResourceA
@ stub D3DXLoadSurfaceFromResourceW

View File

@ -197,3 +197,57 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(LPDIRECT3DSURFACE9 pDestSurface,
if( !pDestSurface || !pSrcData | !SrcDataSize ) return D3DERR_INVALIDCALL;
return E_NOTIMPL;
}
/************************************************************
* D3DXLoadSurfaceFromFile
*/
HRESULT WINAPI D3DXLoadSurfaceFromFileA(LPDIRECT3DSURFACE9 pDestSurface,
CONST PALETTEENTRY *pDestPalette,
CONST RECT *pDestRect,
LPCSTR pSrcFile,
CONST RECT *pSrcRect,
DWORD dwFilter,
D3DCOLOR Colorkey,
D3DXIMAGE_INFO *pSrcInfo)
{
LPWSTR pWidename;
HRESULT hr;
int strlength;
TRACE("(void): relay\n");
if( !pSrcFile || !pDestSurface ) return D3DERR_INVALIDCALL;
strlength = MultiByteToWideChar(CP_ACP, 0, pSrcFile, -1, NULL, 0);
pWidename = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, strlength * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, pSrcFile, -1, pWidename, strlength);
hr = D3DXLoadSurfaceFromFileW(pDestSurface, pDestPalette, pDestRect, pWidename, pSrcRect, dwFilter, Colorkey, pSrcInfo);
HeapFree(GetProcessHeap(), 0, pWidename);
return hr;
}
HRESULT WINAPI D3DXLoadSurfaceFromFileW(LPDIRECT3DSURFACE9 pDestSurface,
CONST PALETTEENTRY *pDestPalette,
CONST RECT *pDestRect,
LPCWSTR pSrcFile,
CONST RECT *pSrcRect,
DWORD Filter,
D3DCOLOR Colorkey,
D3DXIMAGE_INFO *pSrcInfo)
{
HRESULT hr;
DWORD dwSize;
LPVOID pBuffer;
TRACE("(void): relay\n");
if( !pSrcFile || !pDestSurface ) return D3DERR_INVALIDCALL;
hr = map_view_of_file(pSrcFile, &pBuffer, &dwSize);
if(FAILED(hr)) return D3DXERR_INVALIDDATA;
hr = D3DXLoadSurfaceFromFileInMemory(pDestSurface, pDestPalette, pDestRect, pBuffer, dwSize, pSrcRect, Filter, Colorkey, pSrcInfo);
UnmapViewOfFile(pBuffer);
return hr;
}