Rebase against 2dd0fb880c005cd5660928d1646a117407cec238.

This commit is contained in:
Sebastian Lackner
2017-01-31 11:19:50 +01:00
parent 8f474115cd
commit 72479040c5
10 changed files with 96 additions and 270 deletions

View File

@@ -1,62 +0,0 @@
From 252fc281bc7a0dbedec51582534184bfd83137d2 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Tue, 20 Sep 2016 14:13:28 +0800
Subject: windowscodecs: Implement IWICBitmapFrameEncode::SetPalette in PNG
encoder.
---
dlls/windowscodecs/pngformat.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c
index 623577e..1fda2b7 100644
--- a/dlls/windowscodecs/pngformat.c
+++ b/dlls/windowscodecs/pngformat.c
@@ -1359,6 +1359,8 @@ typedef struct PngEncoder {
BYTE *data;
UINT stride;
UINT passes;
+ WICColor palette[256];
+ UINT colors;
} PngEncoder;
static inline PngEncoder *impl_from_IWICBitmapEncoder(IWICBitmapEncoder *iface)
@@ -1536,10 +1538,24 @@ static HRESULT WINAPI PngFrameEncode_SetColorContexts(IWICBitmapFrameEncode *ifa
}
static HRESULT WINAPI PngFrameEncode_SetPalette(IWICBitmapFrameEncode *iface,
- IWICPalette *pIPalette)
+ IWICPalette *palette)
{
- FIXME("(%p,%p): stub\n", iface, pIPalette);
- return WINCODEC_ERR_UNSUPPORTEDOPERATION;
+ PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
+ HRESULT hr;
+
+ TRACE("(%p,%p)\n", iface, palette);
+
+ if (!palette) return E_INVALIDARG;
+
+ EnterCriticalSection(&This->lock);
+
+ if (This->frame_initialized)
+ hr = IWICPalette_GetColors(palette, 256, This->palette, &This->colors);
+ else
+ hr = WINCODEC_ERR_NOTINITIALIZED;
+
+ LeaveCriticalSection(&This->lock);
+ return hr;
}
static HRESULT WINAPI PngFrameEncode_SetThumbnail(IWICBitmapFrameEncode *iface,
@@ -2044,6 +2060,7 @@ HRESULT PngEncoder_CreateInstance(REFIID iid, void** ppv)
This->frame_committed = FALSE;
This->committed = FALSE;
This->data = NULL;
+ This->colors = 0;
InitializeCriticalSection(&This->lock);
This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": PngEncoder.lock");
--
2.9.0

View File

@@ -1,4 +1,4 @@
From 93ab66ef7c5d801936bc90e0e35b5b35db1f387e Mon Sep 17 00:00:00 2001
From c0876d0b4f8e7773db7d97a5d2d287db51cc3177 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Tue, 20 Sep 2016 14:47:48 +0800
Subject: windowscodecs/tests: Add some tests for encoding 1bpp/8bpp images
@@ -9,7 +9,7 @@ Subject: windowscodecs/tests: Add some tests for encoding 1bpp/8bpp images
1 file changed, 340 insertions(+), 19 deletions(-)
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c
index 7ca201a..78bcdbf 100644
index 367df51a0b2..7bfd70bdc21 100644
--- a/dlls/windowscodecs/tests/converter.c
+++ b/dlls/windowscodecs/tests/converter.c
@@ -1,5 +1,6 @@
@@ -27,8 +27,8 @@ index 7ca201a..78bcdbf 100644
#include <math.h>
#define COBJMACROS
@@ -27,6 +29,8 @@
#include "wincodec.h"
@@ -28,6 +30,8 @@
#include "wincodecsdk.h"
#include "wine/test.h"
+static IWICImagingFactory *factory;
@@ -36,7 +36,7 @@ index 7ca201a..78bcdbf 100644
typedef struct bitmap_data {
const WICPixelFormatGUID *format;
UINT bpp;
@@ -231,6 +235,19 @@ static BOOL compare_bits(const struct bitmap_data *expect, UINT buffersize, cons
@@ -232,6 +236,19 @@ static BOOL compare_bits(const struct bitmap_data *expect, UINT buffersize, cons
break;
}
}
@@ -56,7 +56,7 @@ index 7ca201a..78bcdbf 100644
else
equal = (memcmp(expect->bits, converted_bits, buffersize) == 0);
@@ -262,7 +279,7 @@ static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSour
@@ -263,7 +280,7 @@ static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSour
hr = IWICBitmapSource_GetPixelFormat(source, &dst_pixelformat);
ok(SUCCEEDED(hr), "GetPixelFormat(%s) failed, hr=%x\n", name, hr);
@@ -65,7 +65,7 @@ index 7ca201a..78bcdbf 100644
prc.X = 0;
prc.Y = 0;
@@ -286,6 +303,21 @@ static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSour
@@ -287,6 +304,21 @@ static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSour
HeapFree(GetProcessHeap(), 0, converted_bits);
}
@@ -87,7 +87,7 @@ index 7ca201a..78bcdbf 100644
static const BYTE bits_24bppBGR[] = {
255,0,0, 0,255,0, 0,0,255, 0,0,0,
0,255,255, 255,0,255, 255,255,0, 255,255,255};
@@ -553,6 +585,118 @@ static void test_encoder_properties(const CLSID* clsid_encoder, IPropertyBag2 *o
@@ -571,6 +603,118 @@ static void test_encoder_properties(const CLSID* clsid_encoder, IPropertyBag2 *o
}
}
@@ -206,7 +206,7 @@ index 7ca201a..78bcdbf 100644
struct setting {
const WCHAR *name;
PROPBAG2_TYPE type;
@@ -562,7 +706,7 @@ struct setting {
@@ -624,7 +768,7 @@ todo_wine
static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* clsid_encoder,
const struct bitmap_data **dsts, const CLSID *clsid_decoder, WICRect *rc,
@@ -215,7 +215,7 @@ index 7ca201a..78bcdbf 100644
{
HRESULT hr;
IWICBitmapEncoder *encoder;
@@ -591,9 +735,22 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -653,9 +797,22 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
if (hglobal && SUCCEEDED(hr))
{
@@ -238,7 +238,7 @@ index 7ca201a..78bcdbf 100644
i=0;
while (SUCCEEDED(hr) && srcs[i])
{
@@ -627,28 +784,60 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -689,13 +846,20 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
}
}
@@ -260,6 +260,9 @@ index 7ca201a..78bcdbf 100644
hr = IWICBitmapFrameEncode_SetSize(frameencode, srcs[i]->width, srcs[i]->height);
ok(SUCCEEDED(hr), "SetSize failed, hr=%x\n", hr);
@@ -703,17 +867,42 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
if (IsEqualGUID(clsid_encoder, &CLSID_WICPngEncoder))
test_set_frame_palette(frameencode);
+ if (palette)
+ {
@@ -304,7 +307,7 @@ index 7ca201a..78bcdbf 100644
IWICBitmapFrameEncode_Release(frameencode);
IPropertyBag2_Release(options);
@@ -663,6 +852,8 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -728,6 +917,8 @@ 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);
@@ -313,7 +316,7 @@ index 7ca201a..78bcdbf 100644
}
if (SUCCEEDED(hr))
@@ -674,25 +865,105 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -739,25 +930,105 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
if (SUCCEEDED(hr))
{
@@ -420,7 +423,7 @@ index 7ca201a..78bcdbf 100644
IWICBitmapDecoder_Release(decoder);
}
@@ -708,13 +979,31 @@ static void test_encoder(const struct bitmap_data *src, const CLSID* clsid_encod
@@ -773,13 +1044,31 @@ static void test_encoder(const struct bitmap_data *src, const CLSID* clsid_encod
{
const struct bitmap_data *srcs[2];
const struct bitmap_data *dsts[2];
@@ -453,7 +456,7 @@ index 7ca201a..78bcdbf 100644
}
static void test_encoder_rects(void)
@@ -733,20 +1022,20 @@ static void test_encoder_rects(void)
@@ -798,20 +1087,20 @@ static void test_encoder_rects(void)
rc.Width = 4;
rc.Height = 2;
@@ -479,7 +482,7 @@ index 7ca201a..78bcdbf 100644
}
static const struct bitmap_data *multiple_frames[3] = {
@@ -765,8 +1054,14 @@ static const struct setting png_interlace_settings[] = {
@@ -830,8 +1119,14 @@ static const struct setting png_interlace_settings[] = {
START_TEST(converter)
{
@@ -494,7 +497,7 @@ index 7ca201a..78bcdbf 100644
test_conversion(&testdata_32bppBGRA, &testdata_32bppBGR, "BGRA -> BGR", FALSE);
test_conversion(&testdata_32bppBGR, &testdata_32bppBGRA, "BGR -> BGRA", FALSE);
test_conversion(&testdata_32bppBGRA, &testdata_32bppBGRA, "BGRA -> BGRA", FALSE);
@@ -791,22 +1086,48 @@ START_TEST(converter)
@@ -857,22 +1152,48 @@ START_TEST(converter)
test_invalid_conversion();
test_default_converter();
@@ -549,5 +552,5 @@ index 7ca201a..78bcdbf 100644
CoUninitialize();
}
--
2.9.0
2.11.0

View File

@@ -1,26 +1,18 @@
From 8b2f07d7c2e51812617bb58533a17b6f3eccaf05 Mon Sep 17 00:00:00 2001
From d8486a686064dfb9e0ed41968888cbb8f94161f1 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.
---
dlls/windowscodecs/tests/converter.c | 292 ++++++++++++++++++++++++++++++++++-
1 file changed, 286 insertions(+), 6 deletions(-)
dlls/windowscodecs/tests/converter.c | 291 ++++++++++++++++++++++++++++++++++-
1 file changed, 285 insertions(+), 6 deletions(-)
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c
index 78bcdbf..78bc8f5 100644
index 7bfd70bdc21..85214d4fb1f 100644
--- a/dlls/windowscodecs/tests/converter.c
+++ b/dlls/windowscodecs/tests/converter.c
@@ -27,6 +27,7 @@
#include "windef.h"
#include "objbase.h"
#include "wincodec.h"
+#include "wincodecsdk.h"
#include "wine/test.h"
static IWICImagingFactory *factory;
@@ -312,6 +313,20 @@ static const struct bitmap_data testdata_BlackWhite = {
@@ -313,6 +313,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};
@@ -41,7 +33,7 @@ index 78bcdbf..78bc8f5 100644
static const BYTE bits_8bpp[] = {
0,1,2,3,
4,5,6,7};
@@ -585,14 +600,224 @@ static void test_encoder_properties(const CLSID* clsid_encoder, IPropertyBag2 *o
@@ -603,14 +617,224 @@ static void test_encoder_properties(const CLSID* clsid_encoder, IPropertyBag2 *o
}
}
@@ -269,7 +261,7 @@ index 78bcdbf..78bc8f5 100644
}
static unsigned be_uint(unsigned val)
@@ -649,6 +874,28 @@ static void check_png_format(IStream *stream, const WICPixelFormatGUID *format)
@@ -667,6 +891,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);
}
@@ -298,7 +290,7 @@ index 78bcdbf..78bc8f5 100644
else if (IsEqualGUID(format, &GUID_WICPixelFormat8bppIndexed))
{
ok(be_uint(png.width) == 4, "wrong width %u\n", be_uint(png.width));
@@ -829,6 +1076,8 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -894,6 +1140,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 ||
@@ -307,7 +299,7 @@ index 78bcdbf..78bc8f5 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);
}
@@ -913,7 +1162,12 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -978,7 +1226,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))
{
@@ -321,7 +313,7 @@ index 78bcdbf..78bc8f5 100644
ok(colors[0] == 0x11111111, "got %08x (%s)\n", colors[0], name);
ok(colors[1] == 0x22222222, "got %08x (%s)\n", colors[1], name);
@@ -921,8 +1175,11 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -986,8 +1239,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);
@@ -335,7 +327,7 @@ index 78bcdbf..78bc8f5 100644
}
}
else if (IsEqualGUID(clsid_decoder, &CLSID_WICBmpDecoder) ||
@@ -940,6 +1197,17 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -1005,6 +1261,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);
}
@@ -353,7 +345,7 @@ index 78bcdbf..78bc8f5 100644
else
{
ok(count == 2, "expected 2, got %u (%s)\n", count, name);
@@ -1090,6 +1358,10 @@ START_TEST(converter)
@@ -1156,6 +1423,10 @@ START_TEST(converter)
&testdata_BlackWhite, &CLSID_WICPngDecoder, "PNG encoder BlackWhite");
test_encoder(&testdata_1bppIndexed, &CLSID_WICPngEncoder,
&testdata_1bppIndexed, &CLSID_WICPngDecoder, "PNG encoder 1bppIndexed");
@@ -364,7 +356,7 @@ index 78bcdbf..78bc8f5 100644
test_encoder(&testdata_8bppIndexed, &CLSID_WICPngEncoder,
&testdata_8bppIndexed, &CLSID_WICPngDecoder, "PNG encoder 8bppIndexed");
test_encoder(&testdata_24bppBGR, &CLSID_WICPngEncoder,
@@ -1101,6 +1373,10 @@ if (!strcmp(winetest_platform, "windows")) /* FIXME: enable once implemented in
@@ -1167,6 +1438,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");
@@ -375,7 +367,7 @@ index 78bcdbf..78bc8f5 100644
test_encoder(&testdata_8bppIndexed, &CLSID_WICBmpEncoder,
&testdata_8bppIndexed, &CLSID_WICBmpDecoder, "BMP encoder 8bppIndexed");
}
@@ -1113,6 +1389,10 @@ if (!strcmp(winetest_platform, "windows")) /* FIXME: enable once implemented in
@@ -1179,6 +1454,10 @@ if (!strcmp(winetest_platform, "windows")) /* FIXME: enable once implemented in
{
test_encoder(&testdata_1bppIndexed, &CLSID_WICTiffEncoder,
&testdata_1bppIndexed, &CLSID_WICTiffDecoder, "TIFF encoder 1bppIndexed");
@@ -387,5 +379,5 @@ index 78bcdbf..78bc8f5 100644
&testdata_8bppIndexed, &CLSID_WICTiffDecoder, "TIFF encoder 8bppIndexed");
}
--
2.9.0
2.11.0