Update windowscodecs-Palette_Images patchset

Thanks Dmitry Timoshkov
This commit is contained in:
Alistair Leslie-Hughes
2018-03-16 21:35:37 +11:00
parent fa354f3ca5
commit 3f981ccb7f
13 changed files with 373 additions and 175 deletions

View File

@@ -1,18 +1,18 @@
From d8486a686064dfb9e0ed41968888cbb8f94161f1 Mon Sep 17 00:00:00 2001
From 6ef5ce21d7fbbdcf85d6666838a4149502c49785 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 22 Sep 2016 19:15:33 +0800
Subject: windowscodecs/tests: Add tests for encoding 2bpp/4bpp images with a
palette.
Subject: windowscodecs/tests: Add tests for encoding 2bpp/4bpp
images with a palette.
---
dlls/windowscodecs/tests/converter.c | 291 ++++++++++++++++++++++++++++++++++-
1 file changed, 285 insertions(+), 6 deletions(-)
dlls/windowscodecs/tests/converter.c | 337 +++++++++++++++++++++++++++++------
1 file changed, 283 insertions(+), 54 deletions(-)
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c
index 7bfd70bdc21..85214d4fb1f 100644
index 5f9f1d88a3..9b8193d52c 100644
--- a/dlls/windowscodecs/tests/converter.c
+++ b/dlls/windowscodecs/tests/converter.c
@@ -313,6 +313,20 @@ static const struct bitmap_data testdata_BlackWhite = {
@@ -316,6 +316,20 @@ static const struct bitmap_data testdata_BlackWhite = {
static const struct bitmap_data testdata_1bppIndexed = {
&GUID_WICPixelFormat1bppIndexed, 1, bits_1bpp, 32, 2, 96.0, 96.0};
@@ -33,14 +33,13 @@ index 7bfd70bdc21..85214d4fb1f 100644
static const BYTE bits_8bpp[] = {
0,1,2,3,
4,5,6,7};
@@ -603,14 +617,224 @@ static void test_encoder_properties(const CLSID* clsid_encoder, IPropertyBag2 *o
@@ -632,64 +646,224 @@ static void test_encoder_properties(const CLSID* clsid_encoder, IPropertyBag2 *o
}
}
-static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
-static void check_bmp_format(IStream *stream, const struct bitmap_data *data)
+static void load_stream(IUnknown *reader, IStream *stream)
{
- /* FIXME */
+{
+ HRESULT hr;
+ IWICPersistStream *persist;
+#ifdef WORDS_BIGENDIAN
@@ -56,12 +55,14 @@ index 7bfd70bdc21..85214d4fb1f 100644
+ ok(hr == S_OK, "LoadEx failed, hr=%x\n", hr);
+
+ IWICPersistStream_Release(persist);
}
static void check_tiff_format(IStream *stream, const WICPixelFormatGUID *format)
+}
+
+static void check_tiff_format(IStream *stream, const WICPixelFormatGUID *format)
{
- /* FIXME */
+ HRESULT hr;
- BITMAPFILEHEADER bfh;
- BITMAPINFOHEADER bih;
HRESULT hr;
- ULONG len;
+ IWICMetadataReader *reader;
+ PROPVARIANT id, value;
+ struct
@@ -98,11 +99,15 @@ index 7bfd70bdc21..85214d4fb1f 100644
+ ok(hr == S_OK, "CoCreateInstance error %#x\n", hr);
+
+ load_stream((IUnknown *)reader, stream);
+
- hr = IStream_Read(stream, &bfh, sizeof(bfh), &len);
- ok(hr == S_OK, "Failed to read file header, hr %#x.\n", hr);
+ hr = IWICMetadataReader_GetCount(reader, &count);
+ ok(hr == S_OK, "GetCount error %#x\n", hr);
+ ok(count != 0, "wrong count %u\n", count);
+
- hr = IStream_Read(stream, &bih, sizeof(bih), &len);
- ok(hr == S_OK, "Failed to read file header, hr %#x.\n", hr);
+ for (i = 0; i < sizeof(tag)/sizeof(tag[0]); i++)
+ {
+ PropVariantInit(&id);
@@ -121,11 +126,20 @@ index 7bfd70bdc21..85214d4fb1f 100644
+ else
+ tag[i].value[0] = -1;
+ }
+
- ok(bfh.bfType == 0x4d42, "Unexpected header type, %#x.\n", bfh.bfType);
- ok(bfh.bfSize != 0, "Unexpected bitmap size %d.\n", bfh.bfSize);
- ok(bfh.bfReserved1 == 0, "Unexpected bfReserved1 field.\n");
- ok(bfh.bfReserved2 == 0, "Unexpected bfReserved2 field.\n");
+ IWICMetadataReader_Release(reader);
+
- if (IsEqualGUID(data->format, &GUID_WICPixelFormat1bppIndexed)
- || IsEqualGUID(data->format, &GUID_WICPixelFormat8bppIndexed))
+ if (IsEqualGUID(format, &GUID_WICPixelFormatBlackWhite))
+ {
{
- /* TODO: test with actual palette size */
- ok(bfh.bfOffBits > sizeof(bfh) + sizeof(bih), "Unexpected data offset %d, format %s.\n",
- bfh.bfOffBits, wine_dbgstr_guid(data->format));
+ ok(width == 32, "wrong width %u\n", width);
+ ok(height == 2, "wrong height %u\n", height);
+
@@ -133,7 +147,33 @@ index 7bfd70bdc21..85214d4fb1f 100644
+ ok(photo == 1, "wrong photometric %d\n", photo);
+ ok(samples == 1, "wrong samples %d\n", samples);
+ ok(colormap == -1, "wrong colormap %d\n", colormap);
+ }
}
- else
- ok(bfh.bfOffBits == sizeof(bfh) + sizeof(bih), "Unexpected data offset %d, format %s.\n",
- bfh.bfOffBits, wine_dbgstr_guid(data->format));
-
- ok(bih.biSize == sizeof(bih), "Unexpected header size %d.\n", bih.biSize);
- ok(bih.biWidth == data->width, "Unexpected bitmap width %d.\n", bih.biWidth);
- ok(bih.biHeight == data->height, "Unexpected bitmap height %d.\n", bih.biHeight);
- ok(bih.biPlanes == 1, "Unexpected planes count %d.\n", bih.biPlanes);
-
- if (IsEqualGUID(data->format, &GUID_WICPixelFormat1bppIndexed))
- ok(bih.biBitCount == 1, "Unexpected bit count %u, format %s.\n", bih.biBitCount,
- wine_dbgstr_guid(data->format));
- else if (IsEqualGUID(data->format, &GUID_WICPixelFormat8bppIndexed))
- ok(bih.biBitCount == 8, "Unexpected bit count %u, format %s.\n", bih.biBitCount,
- wine_dbgstr_guid(data->format));
- else if (IsEqualGUID(data->format, &GUID_WICPixelFormat32bppBGR))
- ok(bih.biBitCount == 32, "Unexpected bit count %u, format %s.\n", bih.biBitCount,
- wine_dbgstr_guid(data->format));
-
- ok(bih.biCompression == BI_RGB, "Unexpected compression mode %u.\n", bih.biCompression);
-todo_wine
- ok(bih.biSizeImage == 0, "Unexpected image size %d.\n", bih.biSizeImage);
- ok(bih.biXPelsPerMeter == 3780 || broken(bih.biXPelsPerMeter == 0) /* XP */, "Unexpected horz resolution %d.\n",
- bih.biXPelsPerMeter);
- ok(bih.biYPelsPerMeter == 3780 || broken(bih.biYPelsPerMeter == 0) /* XP */, "Unexpected vert resolution %d.\n",
- bih.biYPelsPerMeter);
+ else if (IsEqualGUID(format, &GUID_WICPixelFormat1bppIndexed))
+ {
+ ok(width == 32, "wrong width %u\n", width);
@@ -158,7 +198,8 @@ index 7bfd70bdc21..85214d4fb1f 100644
+ {
+ ok(width == 8, "wrong width %u\n", width);
+ ok(height == 2, "wrong height %u\n", height);
+
- /* FIXME: test actual data */
+ ok(bps == 4, "wrong bps %d\n", bps);
+ ok(photo == 3, "wrong photometric %d\n", photo);
+ ok(samples == 1, "wrong samples %d\n", samples);
@@ -186,10 +227,12 @@ index 7bfd70bdc21..85214d4fb1f 100644
+ }
+ else
+ ok(0, "unknown TIFF pixel format %s\n", wine_dbgstr_guid(format));
+}
+
}
-static void check_tiff_format(IStream *stream, const WICPixelFormatGUID *format)
+static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
+{
{
- /* FIXME */
+ HRESULT hr;
+ BITMAPFILEHEADER bfh;
+ BITMAPV5HEADER bih;
@@ -249,7 +292,7 @@ index 7bfd70bdc21..85214d4fb1f 100644
+ else if (IsEqualGUID(format, &GUID_WICPixelFormat32bppBGR))
+ {
+ ok(bih.bV5Width == 4, "wrong width %u\n", bih.bV5Width);
+ ok(bih.bV5Height == 2 || bih.bV5Height == -2 /* Wine */, "wrong height %u\n", bih.bV5Height);
+ ok(bih.bV5Height == 2, "wrong height %u\n", bih.bV5Height);
+
+ ok(bih.bV5Planes == 1, "wrong Planes %d\n", bih.bV5Planes);
+ ok(bih.bV5BitCount == 32, "wrong BitCount %d\n", bih.bV5BitCount);
@@ -261,7 +304,7 @@ index 7bfd70bdc21..85214d4fb1f 100644
}
static unsigned be_uint(unsigned val)
@@ -667,6 +891,28 @@ static void check_png_format(IStream *stream, const WICPixelFormatGUID *format)
@@ -746,6 +920,28 @@ static void check_png_format(IStream *stream, const WICPixelFormatGUID *format)
ok(png.filter == 0, "wrong filter %d\n", png.filter);
ok(png.interlace == 0, "wrong interlace %d\n", png.interlace);
}
@@ -290,7 +333,31 @@ index 7bfd70bdc21..85214d4fb1f 100644
else if (IsEqualGUID(format, &GUID_WICPixelFormat8bppIndexed))
{
ok(be_uint(png.width) == 4, "wrong width %u\n", be_uint(png.width));
@@ -894,6 +1140,8 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -772,7 +968,7 @@ static void check_png_format(IStream *stream, const WICPixelFormatGUID *format)
ok(0, "unknown PNG pixel format %s\n", wine_dbgstr_guid(format));
}
-static void check_bitmap_format(IStream *stream, const CLSID *encoder, const struct bitmap_data *dst)
+static void check_bitmap_format(IStream *stream, const CLSID *encoder, const WICPixelFormatGUID *format)
{
HRESULT hr;
LARGE_INTEGER pos;
@@ -782,11 +978,11 @@ static void check_bitmap_format(IStream *stream, const CLSID *encoder, const str
ok(hr == S_OK, "IStream_Seek error %#x\n", hr);
if (IsEqualGUID(encoder, &CLSID_WICPngEncoder))
- check_png_format(stream, dst->format);
+ check_png_format(stream, format);
else if (IsEqualGUID(encoder, &CLSID_WICBmpEncoder))
- check_bmp_format(stream, dst);
+ check_bmp_format(stream, format);
else if (IsEqualGUID(encoder, &CLSID_WICTiffEncoder))
- check_tiff_format(stream, dst->format);
+ check_tiff_format(stream, format);
else
ok(0, "unknown encoder %s\n", wine_dbgstr_guid(encoder));
@@ -991,6 +1187,8 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
ok(SUCCEEDED(hr), "WriteSource(%dx%d) failed, hr=%x (%s)\n", rc->Width, rc->Height, hr, name);
else
ok(hr == S_OK ||
@@ -299,7 +366,16 @@ index 7bfd70bdc21..85214d4fb1f 100644
broken(hr == E_INVALIDARG && IsEqualGUID(clsid_encoder, &CLSID_WICBmpEncoder) && IsEqualGUID(srcs[i]->format, &GUID_WICPixelFormatBlackWhite)) /* XP */,
"WriteSource(NULL) failed, hr=%x (%s)\n", hr, name);
}
@@ -978,7 +1226,12 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -1022,7 +1220,7 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
hr = IWICBitmapEncoder_Commit(encoder);
ok(SUCCEEDED(hr), "Commit failed, hr=%x\n", hr);
- check_bitmap_format(stream, clsid_encoder, dsts[0]);
+ check_bitmap_format(stream, clsid_encoder, dsts[0]->format);
}
if (SUCCEEDED(hr))
@@ -1082,7 +1280,12 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
ok(ret == count, "expected %u, got %u\n", count, ret);
if (IsEqualGUID(clsid_decoder, &CLSID_WICPngDecoder))
{
@@ -313,7 +389,7 @@ index 7bfd70bdc21..85214d4fb1f 100644
ok(colors[0] == 0x11111111, "got %08x (%s)\n", colors[0], name);
ok(colors[1] == 0x22222222, "got %08x (%s)\n", colors[1], name);
@@ -986,8 +1239,11 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -1090,8 +1293,11 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
{
ok(colors[2] == 0x33333333, "got %08x (%s)\n", colors[2], name);
ok(colors[3] == 0x44444444, "got %08x (%s)\n", colors[3], name);
@@ -327,7 +403,7 @@ index 7bfd70bdc21..85214d4fb1f 100644
}
}
else if (IsEqualGUID(clsid_decoder, &CLSID_WICBmpDecoder) ||
@@ -1005,6 +1261,17 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -1109,6 +1315,17 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
ok(colors[4] == 0xff555555, "got %08x (%s)\n", colors[4], name);
ok(colors[5] == 0xff000000, "got %08x (%s)\n", colors[5], name);
}
@@ -345,7 +421,7 @@ index 7bfd70bdc21..85214d4fb1f 100644
else
{
ok(count == 2, "expected 2, got %u (%s)\n", count, name);
@@ -1156,6 +1423,10 @@ START_TEST(converter)
@@ -1260,6 +1477,10 @@ START_TEST(converter)
&testdata_BlackWhite, &CLSID_WICPngDecoder, "PNG encoder BlackWhite");
test_encoder(&testdata_1bppIndexed, &CLSID_WICPngEncoder,
&testdata_1bppIndexed, &CLSID_WICPngDecoder, "PNG encoder 1bppIndexed");
@@ -356,7 +432,7 @@ index 7bfd70bdc21..85214d4fb1f 100644
test_encoder(&testdata_8bppIndexed, &CLSID_WICPngEncoder,
&testdata_8bppIndexed, &CLSID_WICPngDecoder, "PNG encoder 8bppIndexed");
test_encoder(&testdata_24bppBGR, &CLSID_WICPngEncoder,
@@ -1167,6 +1438,10 @@ if (!strcmp(winetest_platform, "windows")) /* FIXME: enable once implemented in
@@ -1271,6 +1492,10 @@ if (!strcmp(winetest_platform, "windows")) /* FIXME: enable once implemented in
&testdata_1bppIndexed, &CLSID_WICBmpDecoder, "BMP encoder BlackWhite");
test_encoder(&testdata_1bppIndexed, &CLSID_WICBmpEncoder,
&testdata_1bppIndexed, &CLSID_WICBmpDecoder, "BMP encoder 1bppIndexed");
@@ -367,7 +443,7 @@ index 7bfd70bdc21..85214d4fb1f 100644
test_encoder(&testdata_8bppIndexed, &CLSID_WICBmpEncoder,
&testdata_8bppIndexed, &CLSID_WICBmpDecoder, "BMP encoder 8bppIndexed");
}
@@ -1179,6 +1454,10 @@ if (!strcmp(winetest_platform, "windows")) /* FIXME: enable once implemented in
@@ -1283,6 +1508,10 @@ if (!strcmp(winetest_platform, "windows")) /* FIXME: enable once implemented in
{
test_encoder(&testdata_1bppIndexed, &CLSID_WICTiffEncoder,
&testdata_1bppIndexed, &CLSID_WICTiffDecoder, "TIFF encoder 1bppIndexed");
@@ -379,5 +455,5 @@ index 7bfd70bdc21..85214d4fb1f 100644
&testdata_8bppIndexed, &CLSID_WICTiffDecoder, "TIFF encoder 8bppIndexed");
}
--
2.11.0
2.16.2

View File

@@ -1,7 +1,7 @@
From 8fcfe575232841cbd14f3bc8929595c5d2986960 Mon Sep 17 00:00:00 2001
From 277591557f9b5a0d175460f95bb0be9c7ed93f09 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Tue, 20 Sep 2016 17:17:42 +0800
Subject: [PATCH 2/8] windowscodecs: Use V_UI1() instead of V_UNION() to assign
Subject: windowscodecs: Use V_UI1() instead of V_UNION() to assign
a VT_UI1 variant member.
---
@@ -9,7 +9,7 @@ Subject: [PATCH 2/8] windowscodecs: Use V_UI1() instead of V_UNION() to assign
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c
index 6fe3f19..2238a0e 100644
index 6fe3f19677..2238a0eaa8 100644
--- a/dlls/windowscodecs/tiffformat.c
+++ b/dlls/windowscodecs/tiffformat.c
@@ -1973,7 +1973,7 @@ static HRESULT WINAPI TiffEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
@@ -22,5 +22,5 @@ index 6fe3f19..2238a0e 100644
VariantClear(&v);
if (FAILED(hr))
--
2.7.4
2.16.2

View File

@@ -1,4 +1,4 @@
From 0cf91e33967d5829bfe70d6d9848f08db04d84ca Mon Sep 17 00:00:00 2001
From 53055fb4a5416b70107ca831982a056d38bab210 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Fri, 23 Sep 2016 16:36:50 +0800
Subject: windowscodecs: Add support for palette image formats to TIFF encoder.
@@ -10,7 +10,7 @@ Subject: windowscodecs: Add support for palette image formats to TIFF encoder.
3 files changed, 48 insertions(+), 9 deletions(-)
diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c
index b011d71..b32b294 100644
index b011d71645..b32b294d72 100644
--- a/dlls/windowscodecs/regsvr.c
+++ b/dlls/windowscodecs/regsvr.c
@@ -1211,6 +1211,8 @@ static GUID const * const tiff_decode_formats[] = {
@@ -34,10 +34,10 @@ index b011d71..b32b294 100644
&GUID_WICPixelFormat32bppBGRA,
&GUID_WICPixelFormat32bppPBGRA,
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c
index 660dc79..b99f0f8 100644
index 9b8193d52c..c4cae4f330 100644
--- a/dlls/windowscodecs/tests/converter.c
+++ b/dlls/windowscodecs/tests/converter.c
@@ -723,13 +723,13 @@ static void check_tiff_format(IStream *stream, const WICPixelFormatGUID *format)
@@ -752,13 +752,13 @@ static void check_tiff_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat2bppIndexed))
{
@@ -54,7 +54,7 @@ index 660dc79..b99f0f8 100644
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat4bppIndexed))
{
@@ -1060,8 +1060,9 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -1151,8 +1151,9 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
memcpy(&pixelformat, srcs[i]->format, sizeof(GUID));
hr = IWICBitmapFrameEncode_SetPixelFormat(frameencode, &pixelformat);
ok(SUCCEEDED(hr), "SetPixelFormat failed, hr=%x\n", hr);
@@ -66,7 +66,7 @@ index 660dc79..b99f0f8 100644
hr = IWICBitmapFrameEncode_SetSize(frameencode, srcs[i]->width, srcs[i]->height);
ok(SUCCEEDED(hr), "SetSize failed, hr=%x\n", hr);
@@ -1214,6 +1215,15 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -1315,6 +1316,15 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
ok(colors[4] == 0xff555555, "got %08x (%s)\n", colors[4], name);
ok(colors[5] == 0xff000000, "got %08x (%s)\n", colors[5], name);
}
@@ -82,7 +82,7 @@ index 660dc79..b99f0f8 100644
else if (IsEqualGUID(dsts[i]->format, &GUID_WICPixelFormat4bppIndexed))
{
ok(count == 16, "expected 16, got %u (%s)\n", count, name);
@@ -1403,17 +1413,14 @@ if (!strcmp(winetest_platform, "windows")) /* FIXME: enable once implemented in
@@ -1504,17 +1514,14 @@ if (!strcmp(winetest_platform, "windows")) /* FIXME: enable once implemented in
test_encoder(&testdata_BlackWhite, &CLSID_WICTiffEncoder,
&testdata_BlackWhite, &CLSID_WICTiffDecoder, "TIFF encoder BlackWhite");
@@ -102,7 +102,7 @@ index 660dc79..b99f0f8 100644
&testdata_24bppBGR, &CLSID_WICTiffDecoder, "TIFF encoder 24bppBGR");
diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c
index b4b7e22..946eccd 100644
index 2238a0eaa8..c9d0889b1e 100644
--- a/dlls/windowscodecs/tiffformat.c
+++ b/dlls/windowscodecs/tiffformat.c
@@ -1,5 +1,6 @@
@@ -125,7 +125,7 @@ index b4b7e22..946eccd 100644
case 4:
decode_info->format = &GUID_WICPixelFormat4bppIndexed;
break;
@@ -1409,6 +1416,10 @@ static const struct tiff_encode_format formats[] = {
@@ -1417,6 +1424,10 @@ static const struct tiff_encode_format formats[] = {
{&GUID_WICPixelFormat48bppRGB, 2, 16, 3, 48, 0, 0, 0},
{&GUID_WICPixelFormat64bppRGBA, 2, 16, 4, 64, 1, 2, 0},
{&GUID_WICPixelFormat64bppPRGBA, 2, 16, 4, 64, 1, 1, 0},
@@ -136,7 +136,7 @@ index b4b7e22..946eccd 100644
{0}
};
@@ -1691,6 +1702,21 @@ static HRESULT WINAPI TiffFrameEncode_WritePixels(IWICBitmapFrameEncode *iface,
@@ -1699,6 +1710,21 @@ static HRESULT WINAPI TiffFrameEncode_WritePixels(IWICBitmapFrameEncode *iface,
pTIFFSetField(This->parent->tiff, TIFFTAG_YRESOLUTION, (float)This->yres);
}
@@ -159,5 +159,5 @@ index b4b7e22..946eccd 100644
}
--
2.9.0
2.16.2

View File

@@ -1,73 +0,0 @@
From abeeebfd3c9fc5ed2901ea10de915932c8812c66 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Fri, 23 Sep 2016 17:02:05 +0800
Subject: windowscodecs: Write the image bits as a bottom-top array in BMP
encoder.
This matches what Windows BMP encoder does.
---
dlls/windowscodecs/bmpencode.c | 17 ++++++++++++-----
dlls/windowscodecs/tests/converter.c | 2 +-
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/dlls/windowscodecs/bmpencode.c b/dlls/windowscodecs/bmpencode.c
index 48a8e27..af082ae 100644
--- a/dlls/windowscodecs/bmpencode.c
+++ b/dlls/windowscodecs/bmpencode.c
@@ -292,10 +292,11 @@ static HRESULT WINAPI BmpFrameEncode_Commit(IWICBitmapFrameEncode *iface)
BmpFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
BITMAPFILEHEADER bfh;
BITMAPV5HEADER bih;
- UINT info_size;
+ UINT info_size, i;
LARGE_INTEGER pos;
ULONG byteswritten;
HRESULT hr;
+ const BYTE *bits;
TRACE("(%p)\n", iface);
@@ -308,7 +309,7 @@ static HRESULT WINAPI BmpFrameEncode_Commit(IWICBitmapFrameEncode *iface)
bih.bV5Size = info_size = sizeof(BITMAPINFOHEADER);
bih.bV5Width = This->width;
- bih.bV5Height = -This->height; /* top-down bitmap */
+ bih.bV5Height = This->height; /* bottom-top bitmap */
bih.bV5Planes = 1;
bih.bV5BitCount = This->format->bpp;
bih.bV5Compression = This->format->compression;
@@ -346,9 +347,15 @@ static HRESULT WINAPI BmpFrameEncode_Commit(IWICBitmapFrameEncode *iface)
if (FAILED(hr)) return hr;
if (byteswritten != info_size) return E_FAIL;
- hr = IStream_Write(This->stream, This->bits, bih.bV5SizeImage, &byteswritten);
- if (FAILED(hr)) return hr;
- if (byteswritten != bih.bV5SizeImage) return E_FAIL;
+ /* write the image bits as a bottom-top array */
+ bits = This->bits + bih.bV5SizeImage;
+ for (i = 0; i < This->height; i++)
+ {
+ bits -= This->stride;
+ hr = IStream_Write(This->stream, bits, This->stride, &byteswritten);
+ if (FAILED(hr)) return hr;
+ if (byteswritten != This->stride) return E_FAIL;
+ }
This->committed = TRUE;
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c
index e7b9ba9..865029f 100644
--- a/dlls/windowscodecs/tests/converter.c
+++ b/dlls/windowscodecs/tests/converter.c
@@ -809,7 +809,7 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
else if (IsEqualGUID(format, &GUID_WICPixelFormat32bppBGR))
{
ok(bih.bV5Width == 4, "wrong width %u\n", bih.bV5Width);
- ok(bih.bV5Height == 2 || bih.bV5Height == -2 /* Wine */, "wrong height %u\n", bih.bV5Height);
+ ok(bih.bV5Height == 2, "wrong height %u\n", bih.bV5Height);
ok(bih.bV5Planes == 1, "wrong Planes %d\n", bih.bV5Planes);
ok(bih.bV5BitCount == 32, "wrong BitCount %d\n", bih.bV5BitCount);
--
2.9.0

View File

@@ -1,4 +1,4 @@
From 7f03e6b569bdd3e0b285a3c9ef0953c4115d80a7 Mon Sep 17 00:00:00 2001
From 818ad232038c7b56183f0d20ad4fa93624e09f17 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Fri, 23 Sep 2016 20:17:47 +0800
Subject: windowscodecs: Limit number of colors in a palette in BMP decoder.
@@ -8,7 +8,7 @@ Subject: windowscodecs: Limit number of colors in a palette in BMP decoder.
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/windowscodecs/bmpdecode.c b/dlls/windowscodecs/bmpdecode.c
index 2bcb81e..47f312f 100644
index 2bcb81e0d6..47f312ffcf 100644
--- a/dlls/windowscodecs/bmpdecode.c
+++ b/dlls/windowscodecs/bmpdecode.c
@@ -271,7 +271,7 @@ static HRESULT WINAPI BmpFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface,
@@ -21,5 +21,5 @@ index 2bcb81e..47f312f 100644
tablesize = sizeof(WICColor) * count;
wiccolors = HeapAlloc(GetProcessHeap(), 0, tablesize);
--
2.9.0
2.16.2

View File

@@ -1,4 +1,4 @@
From 417a574db2c401f6b5150683e284418f88a03e67 Mon Sep 17 00:00:00 2001
From 621820e1345fb06680ec25c3c5690a928a2b1141 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Fri, 23 Sep 2016 20:17:47 +0800
Subject: windowscodecs: Add support for palette image formats to BMP encoder.
@@ -11,7 +11,7 @@ Subject: windowscodecs: Add support for palette image formats to BMP encoder.
4 files changed, 60 insertions(+), 15 deletions(-)
diff --git a/dlls/windowscodecs/bmpencode.c b/dlls/windowscodecs/bmpencode.c
index af082ae..d4ec651 100644
index 97f30d7197..86e42b9a68 100644
--- a/dlls/windowscodecs/bmpencode.c
+++ b/dlls/windowscodecs/bmpencode.c
@@ -1,5 +1,6 @@
@@ -53,7 +53,7 @@ index af082ae..d4ec651 100644
#endif
{NULL}
};
@@ -179,11 +186,13 @@ static HRESULT WINAPI BmpFrameEncode_SetPixelFormat(IWICBitmapFrameEncode *iface
@@ -184,11 +191,13 @@ static HRESULT WINAPI BmpFrameEncode_SetPixelFormat(IWICBitmapFrameEncode *iface
for (i=0; formats[i].guid; i++)
{
@@ -68,7 +68,7 @@ index af082ae..d4ec651 100644
This->format = &formats[i];
memcpy(pPixelFormat, This->format->guid, sizeof(GUID));
@@ -202,6 +211,7 @@ static HRESULT WINAPI BmpFrameEncode_SetPalette(IWICBitmapFrameEncode *iface,
@@ -207,6 +216,7 @@ static HRESULT WINAPI BmpFrameEncode_SetPalette(IWICBitmapFrameEncode *iface,
IWICPalette *palette)
{
BmpFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
@@ -76,7 +76,7 @@ index af082ae..d4ec651 100644
TRACE("(%p,%p)\n", iface, palette);
@@ -210,7 +220,14 @@ static HRESULT WINAPI BmpFrameEncode_SetPalette(IWICBitmapFrameEncode *iface,
@@ -215,7 +225,14 @@ static HRESULT WINAPI BmpFrameEncode_SetPalette(IWICBitmapFrameEncode *iface,
if (!This->initialized)
return WINCODEC_ERR_NOTINITIALIZED;
@@ -92,7 +92,7 @@ index af082ae..d4ec651 100644
}
static HRESULT WINAPI BmpFrameEncode_SetThumbnail(IWICBitmapFrameEncode *iface,
@@ -316,8 +333,8 @@ static HRESULT WINAPI BmpFrameEncode_Commit(IWICBitmapFrameEncode *iface)
@@ -330,8 +347,8 @@ static HRESULT WINAPI BmpFrameEncode_Commit(IWICBitmapFrameEncode *iface)
bih.bV5SizeImage = This->stride*This->height;
bih.bV5XPelsPerMeter = (This->xres+0.0127) / 0.0254;
bih.bV5YPelsPerMeter = (This->yres+0.0127) / 0.0254;
@@ -103,7 +103,7 @@ index af082ae..d4ec651 100644
if (This->format->compression == BI_BITFIELDS)
{
@@ -334,6 +351,7 @@ static HRESULT WINAPI BmpFrameEncode_Commit(IWICBitmapFrameEncode *iface)
@@ -348,6 +365,7 @@ static HRESULT WINAPI BmpFrameEncode_Commit(IWICBitmapFrameEncode *iface)
bfh.bfSize = sizeof(BITMAPFILEHEADER) + info_size + bih.bV5SizeImage;
bfh.bfOffBits = sizeof(BITMAPFILEHEADER) + info_size;
@@ -111,7 +111,7 @@ index af082ae..d4ec651 100644
pos.QuadPart = 0;
hr = IStream_Seek(This->stream, pos, STREAM_SEEK_SET, NULL);
@@ -347,6 +365,14 @@ static HRESULT WINAPI BmpFrameEncode_Commit(IWICBitmapFrameEncode *iface)
@@ -361,6 +379,14 @@ static HRESULT WINAPI BmpFrameEncode_Commit(IWICBitmapFrameEncode *iface)
if (FAILED(hr)) return hr;
if (byteswritten != info_size) return E_FAIL;
@@ -123,11 +123,11 @@ index af082ae..d4ec651 100644
+ if (byteswritten != This->colors * sizeof(WICColor)) return E_FAIL;
+ }
+
/* write the image bits as a bottom-top array */
bits = This->bits + bih.bV5SizeImage;
for (i = 0; i < This->height; i++)
hr = IStream_Write(This->stream, This->bits, bih.bV5SizeImage, &byteswritten);
if (FAILED(hr)) return hr;
if (byteswritten != bih.bV5SizeImage) return E_FAIL;
diff --git a/dlls/windowscodecs/info.c b/dlls/windowscodecs/info.c
index 84b80bc..bce2c47 100644
index 6ddfdda25f..fbd0da97cf 100644
--- a/dlls/windowscodecs/info.c
+++ b/dlls/windowscodecs/info.c
@@ -2280,6 +2280,12 @@ HRESULT CreateComponentEnumerator(DWORD componentTypes, DWORD options, IEnumUnkn
@@ -153,7 +153,7 @@ index 84b80bc..bce2c47 100644
IWICBitmapSource_AddRef(pISrc);
*ppIDst = pISrc;
diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c
index b32b294..c72fbf1 100644
index b32b294d72..c72fbf1899 100644
--- a/dlls/windowscodecs/regsvr.c
+++ b/dlls/windowscodecs/regsvr.c
@@ -1347,6 +1347,11 @@ static GUID const * const bmp_encode_formats[] = {
@@ -169,10 +169,10 @@ index b32b294..c72fbf1 100644
};
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c
index dec2ae7..6ee5652 100644
index c4cae4f330..80ef61087d 100644
--- a/dlls/windowscodecs/tests/converter.c
+++ b/dlls/windowscodecs/tests/converter.c
@@ -785,6 +785,8 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
@@ -814,6 +814,8 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
if (IsEqualGUID(format, &GUID_WICPixelFormat1bppIndexed))
{
@@ -181,7 +181,7 @@ index dec2ae7..6ee5652 100644
ok(bih.bV5Width == 32, "wrong width %u\n", bih.bV5Width);
ok(bih.bV5Height == 2, "wrong height %u\n", bih.bV5Height);
@@ -795,6 +797,8 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
@@ -824,6 +826,8 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat2bppIndexed))
{
@@ -190,7 +190,7 @@ index dec2ae7..6ee5652 100644
ok(bih.bV5Width == 16, "wrong width %u\n", bih.bV5Width);
ok(bih.bV5Height == 2, "wrong height %u\n", bih.bV5Height);
@@ -805,6 +809,8 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
@@ -834,6 +838,8 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat4bppIndexed))
{
@@ -199,7 +199,7 @@ index dec2ae7..6ee5652 100644
ok(bih.bV5Width == 8, "wrong width %u\n", bih.bV5Width);
ok(bih.bV5Height == 2, "wrong height %u\n", bih.bV5Height);
@@ -815,6 +821,8 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
@@ -844,6 +850,8 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat8bppIndexed))
{
@@ -208,7 +208,7 @@ index dec2ae7..6ee5652 100644
ok(bih.bV5Width == 4, "wrong width %u\n", bih.bV5Width);
ok(bih.bV5Height == 2, "wrong height %u\n", bih.bV5Height);
@@ -825,6 +833,8 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
@@ -854,6 +862,8 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat32bppBGR))
{
@@ -217,7 +217,7 @@ index dec2ae7..6ee5652 100644
ok(bih.bV5Width == 4, "wrong width %u\n", bih.bV5Width);
ok(bih.bV5Height == 2, "wrong height %u\n", bih.bV5Height);
@@ -1061,7 +1071,8 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -1152,7 +1162,8 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
hr = IWICBitmapFrameEncode_SetPixelFormat(frameencode, &pixelformat);
ok(SUCCEEDED(hr), "SetPixelFormat failed, hr=%x\n", hr);
ok(IsEqualGUID(&pixelformat, dsts[i]->format) ||
@@ -227,7 +227,7 @@ index dec2ae7..6ee5652 100644
"SetPixelFormat changed the format to %s (%s)\n", wine_dbgstr_guid(&pixelformat), name);
hr = IWICBitmapFrameEncode_SetSize(frameencode, srcs[i]->width, srcs[i]->height);
@@ -1395,19 +1406,16 @@ START_TEST(converter)
@@ -1496,19 +1507,16 @@ START_TEST(converter)
test_encoder(&testdata_24bppBGR, &CLSID_WICPngEncoder,
&testdata_24bppBGR, &CLSID_WICPngDecoder, "PNG encoder 24bppBGR");
@@ -249,5 +249,5 @@ index dec2ae7..6ee5652 100644
&testdata_32bppBGR, &CLSID_WICBmpDecoder, "BMP encoder 32bppBGR");
--
2.9.0
2.16.2

View File

@@ -1,4 +1,4 @@
From 6838f692cc7e41dfcae4ee8cf3ee63307a93dd8c Mon Sep 17 00:00:00 2001
From 55f662c7d5e524c33bc588d58580087a68083fbc Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Tue, 4 Oct 2016 18:33:40 +0800
Subject: windowscodecs: find_decoder() should return an error it received from
@@ -13,7 +13,7 @@ instead of WINCODEC_ERR_COMPONENTNOTFOUND.
1 file changed, 23 insertions(+), 19 deletions(-)
diff --git a/dlls/windowscodecs/imgfactory.c b/dlls/windowscodecs/imgfactory.c
index 659aa7e..8c37e3d 100644
index e1bcc89a8b..70f2f0c1f3 100644
--- a/dlls/windowscodecs/imgfactory.c
+++ b/dlls/windowscodecs/imgfactory.c
@@ -120,22 +120,23 @@ static HRESULT WINAPI ComponentFactory_CreateDecoderFromFilename(
@@ -118,5 +118,5 @@ index 659aa7e..8c37e3d 100644
}
--
2.9.0
2.16.2

View File

@@ -1,4 +1,4 @@
From 0d54c3163edd87ef50d4808b4ba5c708f12d1ddd Mon Sep 17 00:00:00 2001
From 828277c6706d2362f49c2a85b5f98ee224c0f059 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Tue, 4 Oct 2016 18:39:40 +0800
Subject: windowscodecs: PNG decoder should return
@@ -10,10 +10,10 @@ Subject: windowscodecs: PNG decoder should return
2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c
index d8b4e2f..9cce735 100644
index 26b5fd52bc..e5ad7876aa 100644
--- a/dlls/windowscodecs/pngformat.c
+++ b/dlls/windowscodecs/pngformat.c
@@ -621,7 +621,7 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p
@@ -622,7 +622,7 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p
ppng_destroy_read_struct(&This->png_ptr, &This->info_ptr, &This->end_info);
HeapFree(GetProcessHeap(), 0, row_pointers);
This->png_ptr = NULL;
@@ -23,10 +23,10 @@ index d8b4e2f..9cce735 100644
}
ppng_set_error_fn(This->png_ptr, jmpbuf, user_error_fn, user_warning_fn);
diff --git a/dlls/windowscodecs/tests/pngformat.c b/dlls/windowscodecs/tests/pngformat.c
index aee8e4e..3747244 100644
index 4b84ccebb1..3a0ea28ead 100644
--- a/dlls/windowscodecs/tests/pngformat.c
+++ b/dlls/windowscodecs/tests/pngformat.c
@@ -725,7 +725,6 @@ static void test_color_formats(void)
@@ -726,7 +726,6 @@ static void test_color_formats(void)
hr = create_decoder(buf, sizeof(buf), &decoder);
if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, TRUE))
@@ -34,7 +34,7 @@ index aee8e4e..3747244 100644
ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr);
else
todo_wine_if(td[i].todo_load)
@@ -754,7 +753,6 @@ next_1:
@@ -755,7 +754,6 @@ next_1:
hr = create_decoder(buf, sizeof(buf), &decoder);
if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, TRUE))
@@ -42,7 +42,7 @@ index aee8e4e..3747244 100644
ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr);
else
todo_wine_if(td[i].todo_load)
@@ -783,7 +781,6 @@ next_2:
@@ -784,7 +782,6 @@ next_2:
hr = create_decoder(buf, sizeof(buf), &decoder);
if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, FALSE))
@@ -50,7 +50,7 @@ index aee8e4e..3747244 100644
ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr);
else
todo_wine_if(td[i].todo_load)
@@ -811,7 +808,6 @@ next_3:
@@ -812,7 +809,6 @@ next_3:
hr = create_decoder(buf, sizeof(buf), &decoder);
if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, FALSE))
@@ -59,5 +59,5 @@ index aee8e4e..3747244 100644
else
todo_wine_if(td[i].todo_load)
--
2.9.0
2.16.2

View File

@@ -1,2 +1,2 @@
Fixes: Improve palette support in windowscodecs.dll
Disabled: true