Commit 43aa3371 authored by Ziqing Hui's avatar Ziqing Hui Committed by Alexandre Julliard

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

parent 6ffc3ecb
......@@ -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__);
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment