From: Ziqing Hui Subject: [PATCH v2 3/3] d3dx10: Implement D3DX10GetImageInfoFromFileA(). Message-Id: Date: Mon, 14 Sep 2020 12:20:32 +0800 Signed-off-by: Ziqing Hui --- v2: * Formatting * Dynamically allocate file name buffer. dlls/d3dx10_43/d3dx10_43_main.c | 24 ++++++++++++++++++++++-- dlls/d3dx10_43/tests/d3dx10.c | 4 +--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/dlls/d3dx10_43/d3dx10_43_main.c b/dlls/d3dx10_43/d3dx10_43_main.c index 62d1067e62..01cda69e5d 100644 --- a/dlls/d3dx10_43/d3dx10_43_main.c +++ b/dlls/d3dx10_43/d3dx10_43_main.c @@ -337,9 +337,29 @@ HRESULT WINAPI D3DX10GetFeatureLevel1(ID3D10Device *device, ID3D10Device1 **devi HRESULT WINAPI D3DX10GetImageInfoFromFileA(const char *src_file, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *info, HRESULT *result) { - FIXME("src_file %s, pump %p, info %p, result %p\n", debugstr_a(src_file), pump, info, result); + WCHAR *buffer; + int str_len; + HRESULT hr; - return E_NOTIMPL; + TRACE("src_file %s, pump %p, info %p, result %p.\n", debugstr_a(src_file), pump, info, result); + + if (!src_file || !info) + return E_FAIL; + + str_len = MultiByteToWideChar(CP_ACP, 0, src_file, -1, NULL, 0); + if (!str_len) + return HRESULT_FROM_WIN32(GetLastError()); + + buffer = HeapAlloc(GetProcessHeap(), 0, str_len * sizeof(*buffer)); + if (!buffer) + return E_OUTOFMEMORY; + + MultiByteToWideChar(CP_ACP, 0, src_file, -1, buffer, str_len); + hr = D3DX10GetImageInfoFromFileW(buffer, pump, info, result); + + HeapFree(GetProcessHeap(), 0, buffer); + + return hr; } HRESULT WINAPI D3DX10GetImageInfoFromFileW(const WCHAR *src_file, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *info, diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 0021c0f0f3..c2327c3a1a 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -1404,12 +1404,10 @@ static void test_get_image_info(void) ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); hr = D3DX10GetImageInfoFromFileW(L"deadbeaf", NULL, &image_info, NULL); ok(hr == D3D10_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#x.\n", hr); - todo_wine { hr = D3DX10GetImageInfoFromFileA(NULL, NULL, &image_info, NULL); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); hr = D3DX10GetImageInfoFromFileA("deadbeaf", NULL, &image_info, NULL); ok(hr == D3D10_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#x.\n", hr); - } for (i = 0; i < ARRAY_SIZE(test_image); ++i) { @@ -1422,7 +1420,7 @@ static void test_get_image_info(void) check_image_info(&image_info, i, __LINE__); hr = D3DX10GetImageInfoFromFileA(get_str_a(path), NULL, &image_info, NULL); - todo_wine + todo_wine_if(test_image[i].expected.ImageFileFormat == D3DX10_IFF_WMP) ok(hr == S_OK, "Test %u: Got unexpected hr %#x.\n", i, hr); if (hr == S_OK) check_image_info(&image_info, i, __LINE__);