d3dx10: Implement D3DX10GetImageInfoFromResource{A, W}().

Signed-off-by: Ziqing Hui <zhui@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ziqing Hui 2020-11-16 10:05:16 +08:00 committed by Alexandre Julliard
parent 6ffc3ecbd8
commit 43aa33714e
2 changed files with 64 additions and 9 deletions

View File

@ -1460,8 +1460,6 @@ static void test_get_image_info(void)
/* D3DX10GetImageInfoFromResource tests */
todo_wine
{
hr = D3DX10GetImageInfoFromResourceW(NULL, NULL, NULL, &image_info, NULL);
ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#x.\n", hr);
hr = D3DX10GetImageInfoFromResourceW(NULL, L"deadbeaf", NULL, &image_info, NULL);
@ -1470,20 +1468,19 @@ static void test_get_image_info(void)
ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#x.\n", hr);
hr = D3DX10GetImageInfoFromResourceA(NULL, "deadbeaf", NULL, &image_info, NULL);
ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#x.\n", hr);
}
for (i = 0; i < ARRAY_SIZE(test_image); ++i)
{
resource_module = create_resource_module(test_resource_name, test_image[i].data, test_image[i].size);
hr = D3DX10GetImageInfoFromResourceW(resource_module, test_resource_name, 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__);
hr = D3DX10GetImageInfoFromResourceA(resource_module, get_str_a(test_resource_name), 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__);

View File

@ -148,6 +148,22 @@ done:
return hr;
}
static HRESULT load_resource(HMODULE module, HRSRC res_info, void **buffer, DWORD *size)
{
HGLOBAL resource;
if (!(*size = SizeofResource(module, res_info)))
return HRESULT_FROM_WIN32(GetLastError());
if (!(resource = LoadResource(module, res_info)))
return HRESULT_FROM_WIN32(GetLastError());
if (!(*buffer = LockResource(resource)))
return HRESULT_FROM_WIN32(GetLastError());
return S_OK;
}
HRESULT WINAPI D3DX10GetImageInfoFromFileA(const char *src_file, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *info,
HRESULT *result)
{
@ -201,19 +217,61 @@ HRESULT WINAPI D3DX10GetImageInfoFromFileW(const WCHAR *src_file, ID3DX10ThreadP
HRESULT WINAPI D3DX10GetImageInfoFromResourceA(HMODULE module, const char *resource, ID3DX10ThreadPump *pump,
D3DX10_IMAGE_INFO *info, HRESULT *result)
{
FIXME("module %p, resource %s, pump %p, info %p, result %p\n",
HRSRC res_info;
void *buffer;
HRESULT hr;
DWORD size;
TRACE("module %p, resource %s, pump %p, info %p, result %p.\n",
module, debugstr_a(resource), pump, info, result);
return E_NOTIMPL;
if (!resource || !info)
return D3DX10_ERR_INVALID_DATA;
res_info = FindResourceA(module, resource, (const char *)RT_RCDATA);
if (!res_info)
{
/* Try loading the resource as bitmap data */
res_info = FindResourceA(module, resource, (const char *)RT_BITMAP);
if (!res_info)
return D3DX10_ERR_INVALID_DATA;
}
hr = load_resource(module, res_info, &buffer, &size);
if (FAILED(hr))
return D3DX10_ERR_INVALID_DATA;
return D3DX10GetImageInfoFromMemory(buffer, size, pump, info, result);
}
HRESULT WINAPI D3DX10GetImageInfoFromResourceW(HMODULE module, const WCHAR *resource, ID3DX10ThreadPump *pump,
D3DX10_IMAGE_INFO *info, HRESULT *result)
{
FIXME("module %p, resource %s, pump %p, info %p, result %p\n",
unsigned int size;
HRSRC res_info;
void *buffer;
HRESULT hr;
TRACE("module %p, resource %s, pump %p, info %p, result %p.\n",
module, debugstr_w(resource), pump, info, result);
return E_NOTIMPL;
if (!resource || !info)
return D3DX10_ERR_INVALID_DATA;
res_info = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA);
if (!res_info)
{
/* Try loading the resource as bitmap data */
res_info = FindResourceW(module, resource, (const WCHAR *)RT_BITMAP);
if (!res_info)
return D3DX10_ERR_INVALID_DATA;
}
hr = load_resource(module, res_info, &buffer, &size);
if (FAILED(hr))
return D3DX10_ERR_INVALID_DATA;
return D3DX10GetImageInfoFromMemory(buffer, size, pump, info, result);
}
HRESULT WINAPI D3DX10GetImageInfoFromMemory(const void *src_data, SIZE_T src_data_size, ID3DX10ThreadPump *pump,