Commit 974e8753 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

windowscodecs: Add test for multi-frame TIFF encoding.

parent 0a5b513d
...@@ -361,8 +361,8 @@ static void test_default_converter(void) ...@@ -361,8 +361,8 @@ static void test_default_converter(void)
DeleteTestBitmap(src_obj); DeleteTestBitmap(src_obj);
} }
static void test_encoder(const struct bitmap_data *src, const CLSID* clsid_encoder, static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* clsid_encoder,
const struct bitmap_data *dst, const CLSID *clsid_decoder, const char *name) const struct bitmap_data **dsts, const CLSID *clsid_decoder, const char *name)
{ {
HRESULT hr; HRESULT hr;
IWICBitmapEncoder *encoder; IWICBitmapEncoder *encoder;
...@@ -374,8 +374,7 @@ static void test_encoder(const struct bitmap_data *src, const CLSID* clsid_encod ...@@ -374,8 +374,7 @@ static void test_encoder(const struct bitmap_data *src, const CLSID* clsid_encod
IWICBitmapDecoder *decoder; IWICBitmapDecoder *decoder;
IWICBitmapFrameDecode *framedecode; IWICBitmapFrameDecode *framedecode;
WICPixelFormatGUID pixelformat; WICPixelFormatGUID pixelformat;
int i;
CreateTestBitmap(src, &src_obj);
hr = CoCreateInstance(clsid_encoder, NULL, CLSCTX_INPROC_SERVER, hr = CoCreateInstance(clsid_encoder, NULL, CLSCTX_INPROC_SERVER,
&IID_IWICBitmapEncoder, (void**)&encoder); &IID_IWICBitmapEncoder, (void**)&encoder);
...@@ -395,32 +394,45 @@ static void test_encoder(const struct bitmap_data *src, const CLSID* clsid_encod ...@@ -395,32 +394,45 @@ static void test_encoder(const struct bitmap_data *src, const CLSID* clsid_encod
hr = IWICBitmapEncoder_Initialize(encoder, stream, WICBitmapEncoderNoCache); hr = IWICBitmapEncoder_Initialize(encoder, stream, WICBitmapEncoderNoCache);
ok(SUCCEEDED(hr), "Initialize failed, hr=%x\n", hr); ok(SUCCEEDED(hr), "Initialize failed, hr=%x\n", hr);
hr = IWICBitmapEncoder_CreateNewFrame(encoder, &frameencode, &options); i=0;
ok(SUCCEEDED(hr), "CreateFrame failed, hr=%x\n", hr); while (SUCCEEDED(hr) && srcs[i])
if (SUCCEEDED(hr))
{ {
hr = IWICBitmapFrameEncode_Initialize(frameencode, options); CreateTestBitmap(srcs[i], &src_obj);
ok(SUCCEEDED(hr), "Initialize failed, hr=%x\n", hr);
hr = IWICBitmapEncoder_CreateNewFrame(encoder, &frameencode, &options);
ok(SUCCEEDED(hr), "CreateFrame failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
{
hr = IWICBitmapFrameEncode_Initialize(frameencode, options);
ok(SUCCEEDED(hr), "Initialize failed, hr=%x\n", hr);
memcpy(&pixelformat, src->format, sizeof(GUID)); memcpy(&pixelformat, srcs[i]->format, sizeof(GUID));
hr = IWICBitmapFrameEncode_SetPixelFormat(frameencode, &pixelformat); hr = IWICBitmapFrameEncode_SetPixelFormat(frameencode, &pixelformat);
ok(SUCCEEDED(hr), "SetPixelFormat failed, hr=%x\n", hr); ok(SUCCEEDED(hr), "SetPixelFormat failed, hr=%x\n", hr);
ok(IsEqualGUID(&pixelformat, src->format), "SetPixelFormat changed the format\n"); ok(IsEqualGUID(&pixelformat, srcs[i]->format), "SetPixelFormat changed the format\n");
hr = IWICBitmapFrameEncode_SetSize(frameencode, src->width, src->height); hr = IWICBitmapFrameEncode_SetSize(frameencode, srcs[i]->width, srcs[i]->height);
ok(SUCCEEDED(hr), "SetSize failed, hr=%x\n", hr); ok(SUCCEEDED(hr), "SetSize failed, hr=%x\n", hr);
hr = IWICBitmapFrameEncode_WriteSource(frameencode, &src_obj->IWICBitmapSource_iface, NULL); hr = IWICBitmapFrameEncode_WriteSource(frameencode, &src_obj->IWICBitmapSource_iface, NULL);
ok(SUCCEEDED(hr), "WriteSource failed, hr=%x\n", hr); ok(SUCCEEDED(hr), "WriteSource failed, hr=%x\n", hr);
hr = IWICBitmapFrameEncode_Commit(frameencode); hr = IWICBitmapFrameEncode_Commit(frameencode);
ok(SUCCEEDED(hr), "Commit failed, hr=%x\n", hr); ok(SUCCEEDED(hr), "Commit failed, hr=%x\n", hr);
IWICBitmapFrameEncode_Release(frameencode);
IPropertyBag2_Release(options);
}
DeleteTestBitmap(src_obj);
i++;
}
if (SUCCEEDED(hr))
{
hr = IWICBitmapEncoder_Commit(encoder); hr = IWICBitmapEncoder_Commit(encoder);
ok(SUCCEEDED(hr), "Commit failed, hr=%x\n", hr); ok(SUCCEEDED(hr), "Commit failed, hr=%x\n", hr);
IWICBitmapFrameEncode_Release(frameencode);
IPropertyBag2_Release(options);
} }
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
...@@ -435,14 +447,20 @@ static void test_encoder(const struct bitmap_data *src, const CLSID* clsid_encod ...@@ -435,14 +447,20 @@ static void test_encoder(const struct bitmap_data *src, const CLSID* clsid_encod
hr = IWICBitmapDecoder_Initialize(decoder, stream, WICDecodeMetadataCacheOnDemand); hr = IWICBitmapDecoder_Initialize(decoder, stream, WICDecodeMetadataCacheOnDemand);
ok(SUCCEEDED(hr), "Initialize failed, hr=%x\n", hr); ok(SUCCEEDED(hr), "Initialize failed, hr=%x\n", hr);
hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode); i=0;
ok(SUCCEEDED(hr), "GetFrame failed, hr=%x\n", hr); while (SUCCEEDED(hr) && dsts[i])
if (SUCCEEDED(hr))
{ {
compare_bitmap_data(dst, (IWICBitmapSource*)framedecode, name); hr = IWICBitmapDecoder_GetFrame(decoder, i, &framedecode);
ok(SUCCEEDED(hr), "GetFrame failed, hr=%x\n", hr);
IWICBitmapFrameDecode_Release(framedecode); if (SUCCEEDED(hr))
{
compare_bitmap_data(dsts[i], (IWICBitmapSource*)framedecode, name);
IWICBitmapFrameDecode_Release(framedecode);
}
i++;
} }
IWICBitmapDecoder_Release(decoder); IWICBitmapDecoder_Release(decoder);
...@@ -453,10 +471,27 @@ static void test_encoder(const struct bitmap_data *src, const CLSID* clsid_encod ...@@ -453,10 +471,27 @@ static void test_encoder(const struct bitmap_data *src, const CLSID* clsid_encod
IWICBitmapEncoder_Release(encoder); IWICBitmapEncoder_Release(encoder);
} }
}
DeleteTestBitmap(src_obj); static void test_encoder(const struct bitmap_data *src, const CLSID* clsid_encoder,
const struct bitmap_data *dst, const CLSID *clsid_decoder, const char *name)
{
const struct bitmap_data *srcs[2];
const struct bitmap_data *dsts[2];
srcs[0] = src;
srcs[1] = NULL;
dsts[0] = dst;
dsts[1] = NULL;
test_multi_encoder(srcs, clsid_encoder, dsts, clsid_decoder, name);
} }
static const struct bitmap_data *multiple_frames[3] = {
&testdata_24bppBGR,
&testdata_24bppBGR,
NULL};
START_TEST(converter) START_TEST(converter)
{ {
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
...@@ -476,5 +511,8 @@ START_TEST(converter) ...@@ -476,5 +511,8 @@ START_TEST(converter)
test_encoder(&testdata_24bppBGR, &CLSID_WICTiffEncoder, test_encoder(&testdata_24bppBGR, &CLSID_WICTiffEncoder,
&testdata_24bppBGR, &CLSID_WICTiffDecoder, "TIFF encoder 24bppBGR"); &testdata_24bppBGR, &CLSID_WICTiffDecoder, "TIFF encoder 24bppBGR");
test_multi_encoder(multiple_frames, &CLSID_WICTiffEncoder,
multiple_frames, &CLSID_WICTiffDecoder, "TIFF encoder multi-frame");
CoUninitialize(); CoUninitialize();
} }
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