windowscodecs-GIF_Encoder: Update patchset.

This commit is contained in:
Sebastian Lackner 2016-11-01 19:21:32 +01:00
parent 5216147032
commit d165f2f23b
18 changed files with 1743 additions and 81 deletions

View File

@ -2064,6 +2064,20 @@ if test "$enable_wined3d_CSMT_Helper" -eq 1; then
enable_wined3d_Silence_FIXMEs=1
fi
if test "$enable_windowscodecs_IWICPalette_InitializeFromBitmap" -eq 1; then
if test "$enable_gdiplus_Grayscale_PNG" -gt 1; then
abort "Patchset gdiplus-Grayscale_PNG disabled, but windowscodecs-IWICPalette_InitializeFromBitmap depends on that."
fi
enable_gdiplus_Grayscale_PNG=1
fi
if test "$enable_windowscodecs_GIF_Encoder" -eq 1; then
if test "$enable_windowscodecs_Palette_Images" -gt 1; then
abort "Patchset windowscodecs-Palette_Images disabled, but windowscodecs-GIF_Encoder depends on that."
fi
enable_windowscodecs_Palette_Images=1
fi
if test "$enable_windowscodecs_Palette_Images" -eq 1; then
if test "$enable_gdiplus_Grayscale_PNG" -gt 1; then
abort "Patchset gdiplus-Grayscale_PNG disabled, but windowscodecs-Palette_Images depends on that."
@ -2075,13 +2089,6 @@ if test "$enable_windowscodecs_Palette_Images" -eq 1; then
enable_windowscodecs_32bppGrayFloat=1
fi
if test "$enable_windowscodecs_IWICPalette_InitializeFromBitmap" -eq 1; then
if test "$enable_gdiplus_Grayscale_PNG" -gt 1; then
abort "Patchset gdiplus-Grayscale_PNG disabled, but windowscodecs-IWICPalette_InitializeFromBitmap depends on that."
fi
enable_gdiplus_Grayscale_PNG=1
fi
if test "$enable_uxtheme_GTK_Theming" -eq 1; then
if test "$enable_ntdll_DllRedirects" -gt 1; then
abort "Patchset ntdll-DllRedirects disabled, but uxtheme-GTK_Theming depends on that."
@ -7206,80 +7213,6 @@ if test "$enable_windowscodecs_32bppGrayFloat" -eq 1; then
) >> "$patchlist"
fi
# Patchset windowscodecs-GIF_Encoder
# |
# | Modified files:
# | * dlls/gdiplus/image.c, dlls/gdiplus/tests/image.c, dlls/windowscodecs/bmpencode.c, dlls/windowscodecs/clsfactory.c,
# | dlls/windowscodecs/gifformat.c, dlls/windowscodecs/info.c, dlls/windowscodecs/jpegformat.c, dlls/windowscodecs/regsvr.c,
# | dlls/windowscodecs/tiffformat.c, dlls/windowscodecs/wincodecs_private.h
# |
if test "$enable_windowscodecs_GIF_Encoder" -eq 1; then
patch_apply windowscodecs-GIF_Encoder/0001-windowscodecs-Implement-IWICBitmapEncoder-GetEncoder.patch
patch_apply windowscodecs-GIF_Encoder/0002-windowscodecs-Implement-IWICBitmapEncoderInfo-GetFil.patch
patch_apply windowscodecs-GIF_Encoder/0003-windowscodecs-Implement-IWICBitmapFrameEncode-SetPal.patch
patch_apply windowscodecs-GIF_Encoder/0004-windowscodecs-Implement-IWICBitmapEncoder-GetEncoder.patch
patch_apply windowscodecs-GIF_Encoder/0005-windowscodecs-Avoid-crashing-if-no-IPropertyBag2-was.patch
patch_apply windowscodecs-GIF_Encoder/0006-windowscodecs-Implement-IWICBitmapEncoder-GetEncoder.patch
patch_apply windowscodecs-GIF_Encoder/0007-windowscodecs-Avoid-crashing-if-no-IPropertyBag2-was.patch
patch_apply windowscodecs-GIF_Encoder/0008-windowscodecs-Add-initial-implementation-of-the-GIF-.patch
patch_apply windowscodecs-GIF_Encoder/0009-gdiplus-Fix-a-typo-in-GIF-container-format-passed-to.patch
patch_apply windowscodecs-GIF_Encoder/0010-windowscodecs-Initialize-empty-property-bag-in-GIF-e.patch
(
echo '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICBitmapEncoder::GetEncoderInfo in BMP encoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICBitmapEncoderInfo::GetFileExtensions.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICBitmapFrameEncode::SetPalette in JPEG encoder,.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICBitmapEncoder::GetEncoderInfo in JPEG encoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Avoid crashing if no IPropertyBag2 was passed to IWICBitmapEncoder::CreateNewFrame in JPEG encoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICBitmapEncoder::GetEncoderInfo in TIFF encoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Avoid crashing if no IPropertyBag2 was passed to IWICBitmapEncoder::CreateNewFrame in TIFF encoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Add initial implementation of the GIF encoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "gdiplus: Fix a typo in GIF container format passed to encode_image_wic().", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Initialize empty property bag in GIF encoder'\''s CreateNewFrame implementation.", 1 },';
) >> "$patchlist"
fi
# Patchset windowscodecs-IMILBitmapSource
# |
# | This patchset fixes the following Wine bugs:
# | * [#34764] Improve compatibility of IMILBitmapSource interface
# |
# | Modified files:
# | * dlls/windowscodecs/bitmap.c, dlls/windowscodecs/scaler.c, dlls/windowscodecs/wincodecs_private.h
# |
if test "$enable_windowscodecs_IMILBitmapSource" -eq 1; then
patch_apply windowscodecs-IMILBitmapSource/0001-windowscodecs-Improve-compatibility-of-IMILBitmapSou.patch
patch_apply windowscodecs-IMILBitmapSource/0002-windowscodecs-Add-support-for-IMILBitmapScaler-inter.patch
(
echo '+ { "Dmitry Timoshkov", "windowscodecs: Improve compatibility of IMILBitmapSource interface.", 3 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Add support for IMILBitmapScaler interface.", 2 },';
) >> "$patchlist"
fi
# Patchset windowscodecs-IWICPalette_InitializeFromBitmap
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * gdiplus-Grayscale_PNG
# |
# | This patchset fixes the following Wine bugs:
# | * [#39890] Implement IWICPalette::InitializeFromBitmap
# |
# | Modified files:
# | * dlls/gdiplus/gdiplus.spec, dlls/gdiplus/image.c, dlls/gdiplus/tests/image.c, dlls/windowscodecs/palette.c,
# | dlls/windowscodecs/tests/palette.c, include/gdiplusflat.h
# |
if test "$enable_windowscodecs_IWICPalette_InitializeFromBitmap" -eq 1; then
patch_apply windowscodecs-IWICPalette_InitializeFromBitmap/0001-windowscodecs-tests-Add-some-tests-for-IWICPalette-I.patch
patch_apply windowscodecs-IWICPalette_InitializeFromBitmap/0002-windowscodecs-Implement-IWICPalette-InitializeFromBi.patch
patch_apply windowscodecs-IWICPalette_InitializeFromBitmap/0003-gdiplus-Implement-GdipInitializePalette.-v2.patch
patch_apply windowscodecs-IWICPalette_InitializeFromBitmap/0004-gdiplus-tests-Add-some-tests-for-GdipInitializePalet.patch
(
echo '+ { "Dmitry Timoshkov", "windowscodecs/tests: Add some tests for IWICPalette::InitializeFromBitmap.", 2 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICPalette::InitializeFromBitmap.", 5 },';
echo '+ { "Dmitry Timoshkov", "gdiplus: Implement GdipInitializePalette.", 2 },';
echo '+ { "Dmitry Timoshkov", "gdiplus/tests: Add some tests for GdipInitializePalette.", 2 },';
) >> "$patchlist"
fi
# Patchset windowscodecs-Palette_Images
# |
# | This patchset has the following (direct or indirect) dependencies:
@ -7339,6 +7272,117 @@ if test "$enable_windowscodecs_Palette_Images" -eq 1; then
) >> "$patchlist"
fi
# Patchset windowscodecs-GIF_Encoder
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * gdiplus-Grayscale_PNG, windowscodecs-32bppGrayFloat, windowscodecs-Palette_Images
# |
# | Modified files:
# | * dlls/gdiplus/image.c, dlls/gdiplus/tests/image.c, dlls/windowscodecs/bmpencode.c, dlls/windowscodecs/clsfactory.c,
# | dlls/windowscodecs/converter.c, dlls/windowscodecs/gifformat.c, dlls/windowscodecs/info.c,
# | dlls/windowscodecs/jpegformat.c, dlls/windowscodecs/metadataquery.c, dlls/windowscodecs/pngformat.c,
# | dlls/windowscodecs/regsvr.c, dlls/windowscodecs/tests/converter.c, dlls/windowscodecs/tiffformat.c,
# | dlls/windowscodecs/wincodecs_private.h, dlls/windowscodecs/windowscodecs_wincodec.idl
# |
if test "$enable_windowscodecs_GIF_Encoder" -eq 1; then
patch_apply windowscodecs-GIF_Encoder/0001-windowscodecs-Implement-IWICBitmapEncoder-GetEncoder.patch
patch_apply windowscodecs-GIF_Encoder/0002-windowscodecs-Implement-IWICBitmapEncoderInfo-GetFil.patch
patch_apply windowscodecs-GIF_Encoder/0003-windowscodecs-Implement-IWICBitmapFrameEncode-SetPal.patch
patch_apply windowscodecs-GIF_Encoder/0004-windowscodecs-Implement-IWICBitmapEncoder-GetEncoder.patch
patch_apply windowscodecs-GIF_Encoder/0005-windowscodecs-Avoid-crashing-if-no-IPropertyBag2-was.patch
patch_apply windowscodecs-GIF_Encoder/0006-windowscodecs-Implement-IWICBitmapEncoder-GetEncoder.patch
patch_apply windowscodecs-GIF_Encoder/0007-windowscodecs-Avoid-crashing-if-no-IPropertyBag2-was.patch
patch_apply windowscodecs-GIF_Encoder/0008-windowscodecs-Add-initial-implementation-of-the-GIF-.patch
patch_apply windowscodecs-GIF_Encoder/0009-gdiplus-Fix-a-typo-in-GIF-container-format-passed-to.patch
patch_apply windowscodecs-GIF_Encoder/0010-windowscodecs-Initialize-empty-property-bag-in-GIF-e.patch
patch_apply windowscodecs-GIF_Encoder/0011-windowscodecs-Add-registration-for-GUID_WICPixelForm.patch
patch_apply windowscodecs-GIF_Encoder/0012-windowscodecs-Implement-IWICBitmapDecoder-GetMetadat.patch
patch_apply windowscodecs-GIF_Encoder/0013-windowscodecs-Improve-stub-for-IWICMetadataQueryRead.patch
patch_apply windowscodecs-GIF_Encoder/0014-windowscodecs-Fix-the-buffer-size-check-in-the-TIFF-.patch
patch_apply windowscodecs-GIF_Encoder/0015-windowscodecs-Add-support-for-converting-to-8bppInde.patch
patch_apply windowscodecs-GIF_Encoder/0016-windowscodecs-WICConvertBitmapSource-should-ask-IWIC.patch
patch_apply windowscodecs-GIF_Encoder/0017-windowscodecs-Implement-IWICBitmapEncoder-GetEncoder.patch
patch_apply windowscodecs-GIF_Encoder/0018-windowscodecs-Implement-IWICBitmapEncoder-GetEncoder.patch
patch_apply windowscodecs-GIF_Encoder/0019-windowscodecs-Improve-stub-for-IWICBitmapDecoder-Get.patch
patch_apply windowscodecs-GIF_Encoder/0020-windowscodecs-Add-registration-of-the-GIF-encoder.patch
patch_apply windowscodecs-GIF_Encoder/0021-windowscodecs-Fix-IWICBitmapDecoder-CopyPalette-for-.patch
patch_apply windowscodecs-GIF_Encoder/0022-windowscodecs-Better-follow-the-GIF-spec-and-don-t-s.patch
patch_apply windowscodecs-GIF_Encoder/0023-windowscodecs-Fix-behaviour-of-format-converter-for-.patch
patch_apply windowscodecs-GIF_Encoder/0024-windowscodecs-tests-Add-a-bunch-of-new-tests-for-ind.patch
patch_apply windowscodecs-GIF_Encoder/0025-windowscodecs-tests-Add-some-tests-for-converting-24.patch
patch_apply windowscodecs-GIF_Encoder/0026-windowscodecs-tests-Add-the-tests-for-GIF-encoder-an.patch
(
echo '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICBitmapEncoder::GetEncoderInfo in BMP encoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICBitmapEncoderInfo::GetFileExtensions.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICBitmapFrameEncode::SetPalette in JPEG encoder,.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICBitmapEncoder::GetEncoderInfo in JPEG encoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Avoid crashing if no IPropertyBag2 was passed to IWICBitmapEncoder::CreateNewFrame in JPEG encoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICBitmapEncoder::GetEncoderInfo in TIFF encoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Avoid crashing if no IPropertyBag2 was passed to IWICBitmapEncoder::CreateNewFrame in TIFF encoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Add initial implementation of the GIF encoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "gdiplus: Fix a typo in GIF container format passed to encode_image_wic().", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Initialize empty property bag in GIF encoder'\''s CreateNewFrame implementation.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Add registration for GUID_WICPixelFormat32bppGrayFloat pixel format.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICBitmapDecoder::GetMetadataQueryReader in the TIFF decoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Improve stub for IWICMetadataQueryReader::GetMetadataByName.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Fix the buffer size check in the TIFF decoder'\''s IWICBitmapFrameDecode::CopyPixels implementation.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Add support for converting to 8bppIndexed format to IWICFormatConverter.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: WICConvertBitmapSource should ask IWICFormatConverter::Initialize to use an optimized palette.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICBitmapEncoder::GetEncoderInfo in the JPEG encoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICBitmapEncoder::GetEncoderInfo in the PNG encoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Improve stub for IWICBitmapDecoder::GetMetadataQueryReader in the PNG decoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Add registration of the GIF encoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Fix IWICBitmapDecoder::CopyPalette for a not initialized case in the GIF decoder.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Better follow the GIF spec and don'\''t specify the local color table size if there is no local palette.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Fix behaviour of format converter for indexed formats when NULL or empty palette has been provided.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs/tests: Add a bunch of new tests for indexed format conversions.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs/tests: Add some tests for converting 24bppBGR to 8bppIndexed format.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs/tests: Add the tests for GIF encoder and decoder.", 1 },';
) >> "$patchlist"
fi
# Patchset windowscodecs-IMILBitmapSource
# |
# | This patchset fixes the following Wine bugs:
# | * [#34764] Improve compatibility of IMILBitmapSource interface
# |
# | Modified files:
# | * dlls/windowscodecs/bitmap.c, dlls/windowscodecs/scaler.c, dlls/windowscodecs/wincodecs_private.h
# |
if test "$enable_windowscodecs_IMILBitmapSource" -eq 1; then
patch_apply windowscodecs-IMILBitmapSource/0001-windowscodecs-Improve-compatibility-of-IMILBitmapSou.patch
patch_apply windowscodecs-IMILBitmapSource/0002-windowscodecs-Add-support-for-IMILBitmapScaler-inter.patch
(
echo '+ { "Dmitry Timoshkov", "windowscodecs: Improve compatibility of IMILBitmapSource interface.", 3 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Add support for IMILBitmapScaler interface.", 2 },';
) >> "$patchlist"
fi
# Patchset windowscodecs-IWICPalette_InitializeFromBitmap
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * gdiplus-Grayscale_PNG
# |
# | This patchset fixes the following Wine bugs:
# | * [#39890] Implement IWICPalette::InitializeFromBitmap
# |
# | Modified files:
# | * dlls/gdiplus/gdiplus.spec, dlls/gdiplus/image.c, dlls/gdiplus/tests/image.c, dlls/windowscodecs/palette.c,
# | dlls/windowscodecs/tests/palette.c, include/gdiplusflat.h
# |
if test "$enable_windowscodecs_IWICPalette_InitializeFromBitmap" -eq 1; then
patch_apply windowscodecs-IWICPalette_InitializeFromBitmap/0001-windowscodecs-tests-Add-some-tests-for-IWICPalette-I.patch
patch_apply windowscodecs-IWICPalette_InitializeFromBitmap/0002-windowscodecs-Implement-IWICPalette-InitializeFromBi.patch
patch_apply windowscodecs-IWICPalette_InitializeFromBitmap/0003-gdiplus-Implement-GdipInitializePalette.-v2.patch
patch_apply windowscodecs-IWICPalette_InitializeFromBitmap/0004-gdiplus-tests-Add-some-tests-for-GdipInitializePalet.patch
(
echo '+ { "Dmitry Timoshkov", "windowscodecs/tests: Add some tests for IWICPalette::InitializeFromBitmap.", 2 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICPalette::InitializeFromBitmap.", 5 },';
echo '+ { "Dmitry Timoshkov", "gdiplus: Implement GdipInitializePalette.", 2 },';
echo '+ { "Dmitry Timoshkov", "gdiplus/tests: Add some tests for GdipInitializePalette.", 2 },';
) >> "$patchlist"
fi
# Patchset windowscodecs-WICCreateBitmapFromSection
# |
# | This patchset fixes the following Wine bugs:

View File

@ -0,0 +1,53 @@
From 6d21d949439cb6e519029aee6bc55693f4cafc6c Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 20 Oct 2016 19:02:39 +0800
Subject: windowscodecs: Add registration for GUID_WICPixelFormat32bppGrayFloat
pixel format.
---
dlls/windowscodecs/regsvr.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c
index 74637f5..4516d3f 100644
--- a/dlls/windowscodecs/regsvr.c
+++ b/dlls/windowscodecs/regsvr.c
@@ -1748,6 +1748,8 @@ static BYTE const channel_mask_16bit2[] = { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
static BYTE const channel_mask_16bit3[] = { 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 };
static BYTE const channel_mask_16bit4[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff };
+static BYTE const channel_mask_32bit[] = { 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 };
+
static BYTE const channel_mask_5bit[] = { 0x1f, 0x00 };
static BYTE const channel_mask_5bit2[] = { 0xe0, 0x03 };
static BYTE const channel_mask_5bit3[] = { 0x00, 0x7c };
@@ -1764,6 +1766,8 @@ static BYTE const * const channel_masks_8bit[] = { channel_mask_8bit,
static BYTE const * const channel_masks_16bit[] = { channel_mask_16bit,
channel_mask_16bit2, channel_mask_16bit3, channel_mask_16bit4};
+static BYTE const * const channel_masks_32bit[] = { channel_mask_32bit };
+
static BYTE const * const channel_masks_BGRA5551[] = { channel_mask_5bit,
channel_mask_5bit2, channel_mask_5bit3, channel_mask_5bit4 };
@@ -1958,6 +1962,17 @@ static struct regsvr_pixelformat const pixelformat_list[] = {
WICPixelFormatNumericRepresentationUnsignedInteger,
1
},
+ { &GUID_WICPixelFormat32bppGrayFloat,
+ "The Wine Project",
+ "32bpp GrayFloat",
+ NULL, /* no version */
+ &GUID_VendorMicrosoft,
+ 32, /* bitsperpixel */
+ 1, /* channel count */
+ channel_masks_32bit,
+ WICPixelFormatNumericRepresentationFloat,
+ 1
+ },
{ &GUID_WICPixelFormat48bppRGB,
"The Wine Project",
"48bpp RGB",
--
2.9.0

View File

@ -0,0 +1,32 @@
From 2297b261c195840bcff9a3db40b25fcaaa747a7b Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 20 Oct 2016 16:49:08 +0800
Subject: windowscodecs: Implement IWICBitmapDecoder::GetMetadataQueryReader in
the TIFF decoder.
---
dlls/windowscodecs/tiffformat.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c
index 037277b..19aa5d5 100644
--- a/dlls/windowscodecs/tiffformat.c
+++ b/dlls/windowscodecs/tiffformat.c
@@ -699,8 +699,12 @@ static HRESULT WINAPI TiffDecoder_CopyPalette(IWICBitmapDecoder *iface,
static HRESULT WINAPI TiffDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface,
IWICMetadataQueryReader **ppIMetadataQueryReader)
{
- FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader);
- return E_NOTIMPL;
+ TRACE("(%p,%p)\n", iface, ppIMetadataQueryReader);
+
+ if (!ppIMetadataQueryReader) return E_INVALIDARG;
+
+ *ppIMetadataQueryReader = NULL;
+ return WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
static HRESULT WINAPI TiffDecoder_GetPreview(IWICBitmapDecoder *iface,
--
2.9.0

View File

@ -0,0 +1,26 @@
From a535cf73bc68b02cfd5fb8d03e86a442f472db4b Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 20 Oct 2016 16:50:20 +0800
Subject: windowscodecs: Improve stub for
IWICMetadataQueryReader::GetMetadataByName.
---
dlls/windowscodecs/metadataquery.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/windowscodecs/metadataquery.c b/dlls/windowscodecs/metadataquery.c
index 10bf295..24de2f8 100644
--- a/dlls/windowscodecs/metadataquery.c
+++ b/dlls/windowscodecs/metadataquery.c
@@ -109,7 +109,7 @@ static HRESULT WINAPI mqr_GetMetadataByName(IWICMetadataQueryReader *iface,
{
QueryReader *This = impl_from_IWICMetadataQueryReader(iface);
FIXME("(%p,%s,%p)\n", This, wine_dbgstr_w(wzName), pvarValue);
- return E_NOTIMPL;
+ return WINCODEC_ERR_PROPERTYNOTFOUND;
}
static HRESULT WINAPI mqr_GetEnumerator(IWICMetadataQueryReader *iface,
--
2.9.0

View File

@ -0,0 +1,30 @@
From d34044e4deedfccf2bb0d7756fbddfd3197116fd Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 20 Oct 2016 19:05:02 +0800
Subject: windowscodecs: Fix the buffer size check in the TIFF decoder's
IWICBitmapFrameDecode::CopyPixels implementation.
Otherwise IWICBitmapSource::CopyPixels() after IWICImagingFactory::CreateBitmapFromSource()
fails for an 24bpp RGB/BGR source.
The check is copied from BMP decoder implementation.
---
dlls/windowscodecs/tiffformat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c
index 19aa5d5..f4f4a49 100644
--- a/dlls/windowscodecs/tiffformat.c
+++ b/dlls/windowscodecs/tiffformat.c
@@ -1106,7 +1106,7 @@ static HRESULT WINAPI TiffFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
if (cbStride < bytesperrow)
return E_INVALIDARG;
- if ((cbStride * prc->Height) > cbBufferSize)
+ if ((cbStride * (prc->Height-1)) + ((prc->Width * This->decode_info.bpp) + 7)/8 > cbBufferSize)
return E_INVALIDARG;
min_tile_x = prc->X / This->decode_info.tile_width;
--
2.9.0

View File

@ -0,0 +1,247 @@
From 663ca5c7923458a158ede7c01aa23805b5941ecc Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 20 Oct 2016 16:56:40 +0800
Subject: windowscodecs: Add support for converting to 8bppIndexed format to
IWICFormatConverter.
---
dlls/windowscodecs/converter.c | 160 ++++++++++++++++++++++++++++++++++++-----
1 file changed, 143 insertions(+), 17 deletions(-)
diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c
index 3704060..c6a2514 100644
--- a/dlls/windowscodecs/converter.c
+++ b/dlls/windowscodecs/converter.c
@@ -76,7 +76,7 @@ typedef struct FormatConverter {
const struct pixelformatinfo *dst_format, *src_format;
WICBitmapDitherType dither;
double alpha_threshold;
- WICBitmapPaletteType palette_type;
+ IWICPalette *palette;
CRITICAL_SECTION lock; /* must be held when initialized */
} FormatConverter;
@@ -1187,11 +1187,96 @@ static HRESULT copypixels_to_8bppGray(struct FormatConverter *This, const WICRec
return hr;
}
+static UINT rgb_to_palette_index(BYTE r, BYTE g, BYTE b, WICColor *colors, UINT count)
+{
+ UINT best_diff, best_index, i;
+
+ best_diff = ~0;
+ best_index = 0;
+
+ for (i = 0; i < count; i++)
+ {
+ BYTE pal_r, pal_g, pal_b;
+ DWORD diff_r, diff_g, diff_b, diff;
+
+ pal_r = colors[i] >> 16;
+ pal_g = colors[i] >> 8;
+ pal_b = colors[i];
+
+ diff_r = r - pal_r;
+ diff_g = g - pal_g;
+ diff_b = b - pal_b;
+
+ diff = diff_r * diff_r + diff_g * diff_g + diff_b * diff_b;
+ if (diff == 0) return i;
+
+ if (diff < best_diff)
+ {
+ best_diff = diff;
+ best_index = i;
+ }
+ }
+
+ return best_index;
+}
+
+static HRESULT copypixels_to_8bppIndexed(struct FormatConverter *This, const WICRect *prc,
+ UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
+{
+ HRESULT hr;
+ BYTE *srcdata;
+ WICColor colors[256];
+ UINT srcstride, srcdatasize, count;
+
+ if (source_format == format_8bppIndexed)
+ {
+ if (prc)
+ return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
+
+ return S_OK;
+ }
+
+ if (!This->palette) return WINCODEC_ERR_WRONGSTATE;
+
+ hr = IWICPalette_GetColors(This->palette, 256, colors, &count);
+ if (hr != S_OK) return hr;
+ if (!count) return WINCODEC_ERR_WRONGSTATE;
+
+ srcstride = 3 * prc->Width;
+ srcdatasize = srcstride * prc->Height;
+
+ srcdata = HeapAlloc(GetProcessHeap(), 0, srcdatasize);
+ if (!srcdata) return E_OUTOFMEMORY;
+
+ hr = copypixels_to_24bppBGR(This, prc, srcstride, srcdatasize, srcdata, source_format);
+ if (SUCCEEDED(hr) && prc)
+ {
+ INT x, y;
+ BYTE *src = srcdata, *dst = pbBuffer;
+
+ for (y = 0; y < prc->Height; y++)
+ {
+ BYTE *bgr = src;
+
+ for (x = 0; x < prc->Width; x++)
+ {
+ dst[x] = rgb_to_palette_index(bgr[2], bgr[1], bgr[0], colors, count);
+ bgr += 3;
+ }
+ src += srcstride;
+ dst += cbStride;
+ }
+ }
+
+ HeapFree(GetProcessHeap(), 0, srcdata);
+ return hr;
+}
+
static const struct pixelformatinfo supported_formats[] = {
{format_1bppIndexed, &GUID_WICPixelFormat1bppIndexed, NULL},
{format_2bppIndexed, &GUID_WICPixelFormat2bppIndexed, NULL},
{format_4bppIndexed, &GUID_WICPixelFormat4bppIndexed, NULL},
- {format_8bppIndexed, &GUID_WICPixelFormat8bppIndexed, NULL},
+ {format_8bppIndexed, &GUID_WICPixelFormat8bppIndexed, copypixels_to_8bppIndexed},
{format_BlackWhite, &GUID_WICPixelFormatBlackWhite, NULL},
{format_2bppGray, &GUID_WICPixelFormat2bppGray, NULL},
{format_4bppGray, &GUID_WICPixelFormat4bppGray, NULL},
@@ -1268,6 +1353,7 @@ static ULONG WINAPI FormatConverter_Release(IWICFormatConverter *iface)
This->lock.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->lock);
if (This->source) IWICBitmapSource_Release(This->source);
+ if (This->palette) IWICPalette_Release(This->palette);
HeapFree(GetProcessHeap(), 0, This);
}
@@ -1316,10 +1402,16 @@ static HRESULT WINAPI FormatConverter_GetResolution(IWICFormatConverter *iface,
}
static HRESULT WINAPI FormatConverter_CopyPalette(IWICFormatConverter *iface,
- IWICPalette *pIPalette)
+ IWICPalette *palette)
{
- FIXME("(%p,%p): stub\n", iface, pIPalette);
- return E_NOTIMPL;
+ FormatConverter *This = impl_from_IWICFormatConverter(iface);
+
+ TRACE("(%p,%p)\n", iface, palette);
+
+ if (!palette) return E_INVALIDARG;
+ if (!This->palette) return WINCODEC_ERR_WRONGSTATE;
+
+ return IWICPalette_InitializeFromPalette(palette, This->palette);
}
static HRESULT WINAPI FormatConverter_CopyPixels(IWICFormatConverter *iface,
@@ -1352,19 +1444,52 @@ static HRESULT WINAPI FormatConverter_CopyPixels(IWICFormatConverter *iface,
}
static HRESULT WINAPI FormatConverter_Initialize(IWICFormatConverter *iface,
- IWICBitmapSource *pISource, REFWICPixelFormatGUID dstFormat, WICBitmapDitherType dither,
- IWICPalette *pIPalette, double alphaThresholdPercent, WICBitmapPaletteType paletteTranslate)
+ IWICBitmapSource *source, REFWICPixelFormatGUID dstFormat, WICBitmapDitherType dither,
+ IWICPalette *palette, double alpha_threshold, WICBitmapPaletteType palette_type)
{
FormatConverter *This = impl_from_IWICFormatConverter(iface);
const struct pixelformatinfo *srcinfo, *dstinfo;
- static INT fixme=0;
GUID srcFormat;
- HRESULT res=S_OK;
+ HRESULT res;
+
+ TRACE("(%p,%p,%s,%u,%p,%0.3f,%u)\n", iface, source, debugstr_guid(dstFormat),
+ dither, palette, alpha_threshold, palette_type);
+
+ if (!palette)
+ {
+ res = PaletteImpl_Create(&palette);
+ if (res != S_OK) return res;
+
+ switch (palette_type)
+ {
+ case WICBitmapPaletteTypeCustom:
+ IWICPalette_Release(palette);
+ palette = NULL;
+ res = S_OK;
+ break;
+
+ case WICBitmapPaletteTypeMedianCut:
+ {
+ UINT bpp;
+ res = get_pixelformat_bpp(dstFormat, &bpp);
+ if (res == S_OK && bpp <= 8)
+ res = IWICPalette_InitializeFromBitmap(palette, source, 1 << bpp, FALSE);
+ break;
+ }
- TRACE("(%p,%p,%s,%u,%p,%0.1f,%u)\n", iface, pISource, debugstr_guid(dstFormat),
- dither, pIPalette, alphaThresholdPercent, paletteTranslate);
+ default:
+ res = IWICPalette_InitializePredefined(palette, palette_type, FALSE);
+ break;
+ }
- if (pIPalette && !fixme++) FIXME("ignoring palette\n");
+ if (res != S_OK)
+ {
+ IWICPalette_Release(palette);
+ return res;
+ }
+ }
+ else
+ IWICPalette_AddRef(palette);
EnterCriticalSection(&This->lock);
@@ -1374,7 +1499,7 @@ static HRESULT WINAPI FormatConverter_Initialize(IWICFormatConverter *iface,
goto end;
}
- res = IWICBitmapSource_GetPixelFormat(pISource, &srcFormat);
+ res = IWICBitmapSource_GetPixelFormat(source, &srcFormat);
if (FAILED(res)) goto end;
srcinfo = get_formatinfo(&srcFormat);
@@ -1395,13 +1520,13 @@ static HRESULT WINAPI FormatConverter_Initialize(IWICFormatConverter *iface,
if (dstinfo->copy_function)
{
- IWICBitmapSource_AddRef(pISource);
+ IWICBitmapSource_AddRef(source);
This->src_format = srcinfo;
This->dst_format = dstinfo;
This->dither = dither;
- This->alpha_threshold = alphaThresholdPercent;
- This->palette_type = paletteTranslate;
- This->source = pISource;
+ This->alpha_threshold = alpha_threshold;
+ This->palette = palette;
+ This->source = source;
}
else
{
@@ -1480,6 +1605,7 @@ HRESULT FormatConverter_CreateInstance(REFIID iid, void** ppv)
This->IWICFormatConverter_iface.lpVtbl = &FormatConverter_Vtbl;
This->ref = 1;
This->source = NULL;
+ This->palette = NULL;
InitializeCriticalSection(&This->lock);
This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": FormatConverter.lock");
--
2.9.0

View File

@ -0,0 +1,28 @@
From 8d2a6325a891a2fab8bf7c091cb8fb73468ae1ea Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 20 Oct 2016 16:57:51 +0800
Subject: windowscodecs: WICConvertBitmapSource should ask
IWICFormatConverter::Initialize to use an optimized palette.
This matches Windows' behaviour, and makes a simple test application that converts
any WIC compatible RGB(A) source image to 8bppIndexed format (GIF for instance) work.
---
dlls/windowscodecs/info.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/windowscodecs/info.c b/dlls/windowscodecs/info.c
index 1a93491..c1e8a66 100644
--- a/dlls/windowscodecs/info.c
+++ b/dlls/windowscodecs/info.c
@@ -2336,7 +2336,7 @@ HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitma
if (SUCCEEDED(res) && canconvert)
res = IWICFormatConverter_Initialize(converter, pISrc, dstFormat, WICBitmapDitherTypeNone,
- NULL, 0.0, WICBitmapPaletteTypeCustom);
+ NULL, 0.0, WICBitmapPaletteTypeMedianCut);
if (FAILED(res) || !canconvert)
{
--
2.9.0

View File

@ -0,0 +1,35 @@
From e2d172c5ac68abd6205c2cb63e2a58597e64ec8c Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Fri, 21 Oct 2016 14:32:25 +0800
Subject: windowscodecs: Implement IWICBitmapEncoder::GetEncoderInfo in the
JPEG encoder.
---
dlls/windowscodecs/jpegformat.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/dlls/windowscodecs/jpegformat.c b/dlls/windowscodecs/jpegformat.c
index 45bb88f..2b1be0a 100644
--- a/dlls/windowscodecs/jpegformat.c
+++ b/dlls/windowscodecs/jpegformat.c
@@ -416,10 +416,14 @@ static HRESULT WINAPI JpegDecoder_CopyPalette(IWICBitmapDecoder *iface,
}
static HRESULT WINAPI JpegDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface,
- IWICMetadataQueryReader **ppIMetadataQueryReader)
+ IWICMetadataQueryReader **reader)
{
- FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader);
- return E_NOTIMPL;
+ FIXME("(%p,%p): stub\n", iface, reader);
+
+ if (!reader) return E_INVALIDARG;
+
+ *reader = NULL;
+ return WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
static HRESULT WINAPI JpegDecoder_GetPreview(IWICBitmapDecoder *iface,
--
2.9.0

View File

@ -0,0 +1,44 @@
From b0dda2778cbd2c33b90f2f500013f48c6fdb0b58 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Fri, 21 Oct 2016 14:36:21 +0800
Subject: windowscodecs: Implement IWICBitmapEncoder::GetEncoderInfo in the PNG
encoder.
---
dlls/windowscodecs/pngformat.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c
index 1a409ae..94253d3 100644
--- a/dlls/windowscodecs/pngformat.c
+++ b/dlls/windowscodecs/pngformat.c
@@ -1936,11 +1936,22 @@ static HRESULT WINAPI PngEncoder_GetContainerFormat(IWICBitmapEncoder *iface,
return E_NOTIMPL;
}
-static HRESULT WINAPI PngEncoder_GetEncoderInfo(IWICBitmapEncoder *iface,
- IWICBitmapEncoderInfo **ppIEncoderInfo)
+static HRESULT WINAPI PngEncoder_GetEncoderInfo(IWICBitmapEncoder *iface, IWICBitmapEncoderInfo **info)
{
- FIXME("(%p,%p): stub\n", iface, ppIEncoderInfo);
- return E_NOTIMPL;
+ IWICComponentInfo *comp_info;
+ HRESULT hr;
+
+ TRACE("%p,%p\n", iface, info);
+
+ if (!info) return E_INVALIDARG;
+
+ hr = CreateComponentInfo(&CLSID_WICPngEncoder, &comp_info);
+ if (hr == S_OK)
+ {
+ hr = IWICComponentInfo_QueryInterface(comp_info, &IID_IWICBitmapEncoderInfo, (void **)info);
+ IWICComponentInfo_Release(comp_info);
+ }
+ return hr;
}
static HRESULT WINAPI PngEncoder_SetColorContexts(IWICBitmapEncoder *iface,
--
2.9.0

View File

@ -0,0 +1,35 @@
From 3204ee4de19693fd9e451a62216b68fe51ea2ca5 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Fri, 21 Oct 2016 14:38:43 +0800
Subject: windowscodecs: Improve stub for
IWICBitmapDecoder::GetMetadataQueryReader in the PNG decoder.
---
dlls/windowscodecs/pngformat.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c
index 94253d3..41d9099 100644
--- a/dlls/windowscodecs/pngformat.c
+++ b/dlls/windowscodecs/pngformat.c
@@ -853,10 +853,14 @@ static HRESULT WINAPI PngDecoder_CopyPalette(IWICBitmapDecoder *iface,
}
static HRESULT WINAPI PngDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface,
- IWICMetadataQueryReader **ppIMetadataQueryReader)
+ IWICMetadataQueryReader **reader)
{
- FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader);
- return E_NOTIMPL;
+ FIXME("(%p,%p): stub\n", iface, reader);
+
+ if (!reader) return E_INVALIDARG;
+
+ *reader = NULL;
+ return WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
static HRESULT WINAPI PngDecoder_GetPreview(IWICBitmapDecoder *iface,
--
2.9.0

View File

@ -0,0 +1,30 @@
From 82ead58d02badf4e84124277868942b089d9b7ba Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 27 Oct 2016 14:48:45 +0800
Subject: windowscodecs: Add registration of the GIF encoder.
---
dlls/windowscodecs/windowscodecs_wincodec.idl | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/dlls/windowscodecs/windowscodecs_wincodec.idl b/dlls/windowscodecs/windowscodecs_wincodec.idl
index fd7ff01..1681b1d 100644
--- a/dlls/windowscodecs/windowscodecs_wincodec.idl
+++ b/dlls/windowscodecs/windowscodecs_wincodec.idl
@@ -70,6 +70,13 @@ coclass WICBmpEncoder { interface IWICBitmapEncoder; }
coclass WICGifDecoder { interface IWICBitmapDecoder; }
[
+ helpstring("WIC GIF Encoder"),
+ threading(both),
+ uuid(114f5598-0b22-40a0-86a1-c83ea495adbd)
+]
+coclass WICGifEncoder { interface IWICBitmapEncoder; }
+
+[
helpstring("WIC ICO Decoder"),
threading(both),
uuid(c61bfcdf-2e0f-4aad-a8d7-e06bafebcdfe)
--
2.9.0

View File

@ -0,0 +1,27 @@
From fe01c9d286b55485fc241f42a617a3a75f2553c4 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 27 Oct 2016 14:50:03 +0800
Subject: windowscodecs: Fix IWICBitmapDecoder::CopyPalette for a not
initialized case in the GIF decoder.
---
dlls/windowscodecs/gifformat.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/dlls/windowscodecs/gifformat.c b/dlls/windowscodecs/gifformat.c
index 6052726..3dac59e 100644
--- a/dlls/windowscodecs/gifformat.c
+++ b/dlls/windowscodecs/gifformat.c
@@ -1198,6 +1198,9 @@ static HRESULT WINAPI GifDecoder_CopyPalette(IWICBitmapDecoder *iface, IWICPalet
TRACE("(%p,%p)\n", iface, palette);
+ if (!This->gif)
+ return WINCODEC_ERR_WRONGSTATE;
+
cm = This->gif->SColorMap;
if (cm)
{
--
2.9.0

View File

@ -0,0 +1,30 @@
From 855d2b2c5a978f441a2f2f1343fb53b03b3568c9 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 27 Oct 2016 14:52:43 +0800
Subject: windowscodecs: Better follow the GIF spec and don't specify the local
color table size if there is no local palette.
---
dlls/windowscodecs/gifformat.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/windowscodecs/gifformat.c b/dlls/windowscodecs/gifformat.c
index 3dac59e..9d0ae6b 100644
--- a/dlls/windowscodecs/gifformat.c
+++ b/dlls/windowscodecs/gifformat.c
@@ -2070,9 +2070,11 @@ static HRESULT WINAPI GifFrameEncode_Commit(IWICBitmapFrameEncode *iface)
imd.height = This->height;
imd.packed = 0;
if (This->colors)
+ {
imd.packed |= 0x80; /* local color table flag */
+ imd.packed |= 0x07; /* local color table size */
+ }
/* FIXME: interlace flag */
- imd.packed |= 0x07; /* local color table size */
hr = IStream_Write(This->encoder->stream, &imd, sizeof(imd), NULL);
if (hr == S_OK && This->colors)
{
--
2.9.0

View File

@ -0,0 +1,100 @@
From 9ddafc9d2cd0fc899e513807a34ef4e875851fca Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 27 Oct 2016 14:55:03 +0800
Subject: windowscodecs: Fix behaviour of format converter for indexed formats
when NULL or empty palette has been provided.
---
dlls/windowscodecs/converter.c | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)
diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c
index c6a2514..4ee980e 100644
--- a/dlls/windowscodecs/converter.c
+++ b/dlls/windowscodecs/converter.c
@@ -1240,7 +1240,6 @@ static HRESULT copypixels_to_8bppIndexed(struct FormatConverter *This, const WIC
hr = IWICPalette_GetColors(This->palette, 256, colors, &count);
if (hr != S_OK) return hr;
- if (!count) return WINCODEC_ERR_WRONGSTATE;
srcstride = 3 * prc->Width;
srcdatasize = srcstride * prc->Height;
@@ -1409,7 +1408,18 @@ static HRESULT WINAPI FormatConverter_CopyPalette(IWICFormatConverter *iface,
TRACE("(%p,%p)\n", iface, palette);
if (!palette) return E_INVALIDARG;
- if (!This->palette) return WINCODEC_ERR_WRONGSTATE;
+ if (!This->source) return WINCODEC_ERR_WRONGSTATE;
+
+ if (!This->palette)
+ {
+ HRESULT hr;
+ UINT bpp;
+
+ hr = get_pixelformat_bpp(This->dst_format->guid, &bpp);
+ if (hr != S_OK) return hr;
+ if (bpp <= 8) return WINCODEC_ERR_WRONGSTATE;
+ return IWICBitmapSource_CopyPalette(This->source, palette);
+ }
return IWICPalette_InitializeFromPalette(palette, This->palette);
}
@@ -1440,7 +1450,7 @@ static HRESULT WINAPI FormatConverter_CopyPixels(IWICFormatConverter *iface,
pbBuffer, This->src_format->format);
}
else
- return WINCODEC_ERR_NOTINITIALIZED;
+ return WINCODEC_ERR_WRONGSTATE;
}
static HRESULT WINAPI FormatConverter_Initialize(IWICFormatConverter *iface,
@@ -1457,6 +1467,10 @@ static HRESULT WINAPI FormatConverter_Initialize(IWICFormatConverter *iface,
if (!palette)
{
+ UINT bpp;
+ res = get_pixelformat_bpp(dstFormat, &bpp);
+ if (res != S_OK) return res;
+
res = PaletteImpl_Create(&palette);
if (res != S_OK) return res;
@@ -1465,20 +1479,19 @@ static HRESULT WINAPI FormatConverter_Initialize(IWICFormatConverter *iface,
case WICBitmapPaletteTypeCustom:
IWICPalette_Release(palette);
palette = NULL;
- res = S_OK;
+ if (bpp <= 8) return E_INVALIDARG;
break;
case WICBitmapPaletteTypeMedianCut:
{
- UINT bpp;
- res = get_pixelformat_bpp(dstFormat, &bpp);
- if (res == S_OK && bpp <= 8)
+ if (bpp <= 8)
res = IWICPalette_InitializeFromBitmap(palette, source, 1 << bpp, FALSE);
break;
}
default:
- res = IWICPalette_InitializePredefined(palette, palette_type, FALSE);
+ if (bpp <= 8)
+ res = IWICPalette_InitializePredefined(palette, palette_type, FALSE);
break;
}
@@ -1538,6 +1551,9 @@ end:
LeaveCriticalSection(&This->lock);
+ if (res != S_OK && palette)
+ IWICPalette_Release(palette);
+
return res;
}
--
2.9.0

View File

@ -0,0 +1,581 @@
From 63254aa83cdb09ad7b0a56a6da1f0d8c7465733e Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 27 Oct 2016 15:10:09 +0800
Subject: windowscodecs/tests: Add a bunch of new tests for indexed format
conversions.
---
dlls/windowscodecs/tests/converter.c | 285 +++++++++++++++++++++++++----------
1 file changed, 209 insertions(+), 76 deletions(-)
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c
index feeca5b..e6d21ac 100644
--- a/dlls/windowscodecs/tests/converter.c
+++ b/dlls/windowscodecs/tests/converter.c
@@ -115,9 +115,30 @@ static HRESULT WINAPI BitmapTestSrc_GetResolution(IWICBitmapSource *iface,
}
static HRESULT WINAPI BitmapTestSrc_CopyPalette(IWICBitmapSource *iface,
- IWICPalette *pIPalette)
+ IWICPalette *palette)
{
- return E_NOTIMPL;
+ BitmapTestSrc *This = impl_from_IWICBitmapSource(iface);
+
+ if (IsEqualGUID(This->data->format, &GUID_WICPixelFormat1bppIndexed) ||
+ IsEqualGUID(This->data->format, &GUID_WICPixelFormat2bppIndexed) ||
+ IsEqualGUID(This->data->format, &GUID_WICPixelFormat4bppIndexed) ||
+ IsEqualGUID(This->data->format, &GUID_WICPixelFormat8bppIndexed))
+ {
+ WICColor colors[8];
+
+ colors[0] = 0xff0000ff;
+ colors[1] = 0xff00ff00;
+ colors[2] = 0xffff0000;
+ colors[3] = 0xff000000;
+ colors[4] = 0xffffff00;
+ colors[5] = 0xffff00ff;
+ colors[6] = 0xff00ffff;
+ colors[7] = 0xffffffff;
+ return IWICPalette_InitializeCustom(palette, colors, 8);
+ }
+
+ /* unique error marker */
+ return 0xdeadbeef;
}
static HRESULT WINAPI BitmapTestSrc_CopyPixels(IWICBitmapSource *iface,
@@ -249,6 +270,21 @@ static BOOL compare_bits(const struct bitmap_data *expect, UINT buffersize, cons
break;
}
}
+ else if (IsEqualGUID(expect->format, &GUID_WICPixelFormat2bppIndexed) ||
+ IsEqualGUID(expect->format, &GUID_WICPixelFormat4bppIndexed) ||
+ IsEqualGUID(expect->format, &GUID_WICPixelFormat8bppIndexed))
+ {
+ UINT i;
+ const BYTE *a=(const BYTE*)expect->bits, *b=(const BYTE*)converted_bits;
+ equal=TRUE;
+
+ for (i=0; i<buffersize; i++)
+ if (a[i] != b[i])
+ {
+ equal = FALSE;
+ break;
+ }
+ }
else
equal = (memcmp(expect->bits, converted_bits, buffersize) == 0);
@@ -258,7 +294,19 @@ static BOOL compare_bits(const struct bitmap_data *expect, UINT buffersize, cons
return equal;
}
-static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSource *source, const char *name)
+static BOOL is_indexed_format(const GUID *format)
+{
+ if (IsEqualGUID(format, &GUID_WICPixelFormat1bppIndexed) ||
+ IsEqualGUID(format, &GUID_WICPixelFormat2bppIndexed) ||
+ IsEqualGUID(format, &GUID_WICPixelFormat4bppIndexed) ||
+ IsEqualGUID(format, &GUID_WICPixelFormat8bppIndexed))
+ return TRUE;
+
+ return FALSE;
+}
+
+static void compare_bitmap_data(const struct bitmap_data *src, const struct bitmap_data *expect,
+ IWICBitmapSource *source, const char *name)
{
BYTE *converted_bits;
UINT width, height;
@@ -291,15 +339,24 @@ static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSour
buffersize = stride * expect->height;
converted_bits = HeapAlloc(GetProcessHeap(), 0, buffersize);
+ memset(converted_bits, 0xaa, buffersize);
hr = IWICBitmapSource_CopyPixels(source, &prc, stride, buffersize, converted_bits);
ok(SUCCEEDED(hr), "CopyPixels(%s) failed, hr=%x\n", name, hr);
- ok(compare_bits(expect, buffersize, converted_bits), "unexpected pixel data (%s)\n", name);
+
+ /* The result of conversion of color to indexed formats depends on
+ * optimized palette generation implementation. We either need to
+ * assign our own palette, or just skip the comparison.
+ */
+ if (!(!is_indexed_format(src->format) && is_indexed_format(expect->format)))
+ ok(compare_bits(expect, buffersize, converted_bits), "unexpected pixel data (%s)\n", name);
/* Test with NULL rectangle - should copy the whole bitmap */
memset(converted_bits, 0xaa, buffersize);
hr = IWICBitmapSource_CopyPixels(source, NULL, stride, buffersize, converted_bits);
ok(SUCCEEDED(hr), "CopyPixels(%s,rc=NULL) failed, hr=%x\n", name, hr);
- ok(compare_bits(expect, buffersize, converted_bits), "unexpected pixel data (%s)\n", name);
+ /* see comment above */
+ if (!(!is_indexed_format(src->format) && is_indexed_format(expect->format)))
+ ok(compare_bits(expect, buffersize, converted_bits), "unexpected pixel data (%s)\n", name);
HeapFree(GetProcessHeap(), 0, converted_bits);
}
@@ -315,78 +372,137 @@ static const struct bitmap_data testdata_1bppIndexed = {
/* some encoders (like BMP) require data to be 4-bytes aligned */
static const BYTE bits_2bpp[] = {
- 0x55,0x55,0x55,0x55,
- 0xaa,0xaa,0xaa,0xaa};
+ 0xdb,0xdb,0xdb,0xdb,0xdb,0xdb,0xdb,0xdb,
+ 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24};
static const struct bitmap_data testdata_2bppIndexed = {
- &GUID_WICPixelFormat2bppIndexed, 2, bits_2bpp, 16, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat2bppIndexed, 2, bits_2bpp, 32, 2, 96.0, 96.0};
/* some encoders (like BMP) require data to be 4-bytes aligned */
static const BYTE bits_4bpp[] = {
- 0x55,0x55,0x55,0x55,
- 0xaa,0xaa,0xaa,0xaa};
+ 0x01,0x23,0x01,0x23,0x01,0x23,0x01,0x23,0x01,0x23,0x01,0x23,0x01,0x23,0x01,0x23,
+ 0x45,0x67,0x45,0x67,0x45,0x67,0x45,0x67,0x45,0x67,0x45,0x67,0x45,0x67,0x45,0x67};
+
static const struct bitmap_data testdata_4bppIndexed = {
- &GUID_WICPixelFormat4bppIndexed, 4, bits_4bpp, 8, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat4bppIndexed, 4, bits_4bpp, 32, 2, 96.0, 96.0};
+
+static const BYTE bits_8bpp_BW[] = {
+ 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,
+ 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0};
+static const struct bitmap_data testdata_8bppIndexed_BW = {
+ &GUID_WICPixelFormat8bppIndexed, 8, bits_8bpp_BW, 32, 2, 96.0, 96.0};
+
+static const BYTE bits_8bpp_4colors[] = {
+ 0,1,2,0,0,1,2,0,0,1,2,0,0,1,2,0,0,1,2,0,0,1,2,0,0,1,2,0,0,1,2,0,
+ 3,2,1,3,3,2,1,3,3,2,1,3,3,2,1,3,3,2,1,3,3,2,1,3,3,2,1,3,3,2,1,3};
+static const struct bitmap_data testdata_8bppIndexed_4colors = {
+ &GUID_WICPixelFormat8bppIndexed, 8, bits_8bpp_4colors, 32, 2, 96.0, 96.0};
static const BYTE bits_8bpp[] = {
- 0,1,2,3,
- 4,5,6,7};
+ 0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,
+ 4,5,6,7,4,5,6,7,4,5,6,7,4,5,6,7,4,5,6,7,4,5,6,7,4,5,6,7,4,5,6,7};
static const struct bitmap_data testdata_8bppIndexed = {
- &GUID_WICPixelFormat8bppIndexed, 8, bits_8bpp, 4, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat8bppIndexed, 8, bits_8bpp, 32, 2, 96.0, 96.0};
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};
+ 255,0,0, 0,255,0, 0,0,255, 0,0,0, 255,0,0, 0,255,0, 0,0,255, 0,0,0,
+ 255,0,0, 0,255,0, 0,0,255, 0,0,0, 255,0,0, 0,255,0, 0,0,255, 0,0,0,
+ 255,0,0, 0,255,0, 0,0,255, 0,0,0, 255,0,0, 0,255,0, 0,0,255, 0,0,0,
+ 255,0,0, 0,255,0, 0,0,255, 0,0,0, 255,0,0, 0,255,0, 0,0,255, 0,0,0,
+ 0,255,255, 255,0,255, 255,255,0, 255,255,255, 0,255,255, 255,0,255, 255,255,0, 255,255,255,
+ 0,255,255, 255,0,255, 255,255,0, 255,255,255, 0,255,255, 255,0,255, 255,255,0, 255,255,255,
+ 0,255,255, 255,0,255, 255,255,0, 255,255,255, 0,255,255, 255,0,255, 255,255,0, 255,255,255,
+ 0,255,255, 255,0,255, 255,255,0, 255,255,255, 0,255,255, 255,0,255, 255,255,0, 255,255,255};
static const struct bitmap_data testdata_24bppBGR = {
- &GUID_WICPixelFormat24bppBGR, 24, bits_24bppBGR, 4, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat24bppBGR, 24, bits_24bppBGR, 32, 2, 96.0, 96.0};
static const BYTE bits_24bppRGB[] = {
- 0,0,255, 0,255,0, 255,0,0, 0,0,0,
- 255,255,0, 255,0,255, 0,255,255, 255,255,255};
+ 0,0,255, 0,255,0, 255,0,0, 0,0,0, 0,0,255, 0,255,0, 255,0,0, 0,0,0,
+ 0,0,255, 0,255,0, 255,0,0, 0,0,0, 0,0,255, 0,255,0, 255,0,0, 0,0,0,
+ 0,0,255, 0,255,0, 255,0,0, 0,0,0, 0,0,255, 0,255,0, 255,0,0, 0,0,0,
+ 0,0,255, 0,255,0, 255,0,0, 0,0,0, 0,0,255, 0,255,0, 255,0,0, 0,0,0,
+ 255,255,0, 255,0,255, 0,255,255, 255,255,255, 255,255,0, 255,0,255, 0,255,255, 255,255,255,
+ 255,255,0, 255,0,255, 0,255,255, 255,255,255, 255,255,0, 255,0,255, 0,255,255, 255,255,255,
+ 255,255,0, 255,0,255, 0,255,255, 255,255,255, 255,255,0, 255,0,255, 0,255,255, 255,255,255,
+ 255,255,0, 255,0,255, 0,255,255, 255,255,255, 255,255,0, 255,0,255, 0,255,255, 255,255,255 };
static const struct bitmap_data testdata_24bppRGB = {
- &GUID_WICPixelFormat24bppRGB, 24, bits_24bppRGB, 4, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat24bppRGB, 24, bits_24bppRGB, 32, 2, 96.0, 96.0};
static const BYTE bits_32bppBGR[] = {
- 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80,
- 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80};
+ 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80, 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80,
+ 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80, 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80,
+ 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80, 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80,
+ 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80, 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80,
+ 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80, 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80,
+ 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80, 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80,
+ 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80, 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80,
+ 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80, 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80};
static const struct bitmap_data testdata_32bppBGR = {
- &GUID_WICPixelFormat32bppBGR, 32, bits_32bppBGR, 4, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat32bppBGR, 32, bits_32bppBGR, 32, 2, 96.0, 96.0};
static const BYTE bits_32bppBGRA[] = {
- 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255,
- 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255};
+ 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255, 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255,
+ 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255, 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255,
+ 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255, 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255,
+ 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255, 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255,
+ 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255, 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255,
+ 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255, 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255,
+ 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255, 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255,
+ 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255, 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255};
static const struct bitmap_data testdata_32bppBGRA = {
- &GUID_WICPixelFormat32bppBGRA, 32, bits_32bppBGRA, 4, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat32bppBGRA, 32, bits_32bppBGRA, 32, 2, 96.0, 96.0};
/* XP and 2003 use linear color conversion, later versions use sRGB gamma */
static const float bits_32bppGrayFloat_xp[] = {
- 0.114000f,0.587000f,0.299000f,0.000000f,
- 0.886000f,0.413000f,0.701000f,1.000000f};
+ 0.114000f,0.587000f,0.299000f,0.000000f,0.114000f,0.587000f,0.299000f,0.000000f,
+ 0.114000f,0.587000f,0.299000f,0.000000f,0.114000f,0.587000f,0.299000f,0.000000f,
+ 0.114000f,0.587000f,0.299000f,0.000000f,0.114000f,0.587000f,0.299000f,0.000000f,
+ 0.114000f,0.587000f,0.299000f,0.000000f,0.114000f,0.587000f,0.299000f,0.000000f,
+ 0.886000f,0.413000f,0.701000f,1.000000f,0.886000f,0.413000f,0.701000f,1.000000f,
+ 0.886000f,0.413000f,0.701000f,1.000000f,0.886000f,0.413000f,0.701000f,1.000000f,
+ 0.886000f,0.413000f,0.701000f,1.000000f,0.886000f,0.413000f,0.701000f,1.000000f,
+ 0.886000f,0.413000f,0.701000f,1.000000f,0.886000f,0.413000f,0.701000f,1.000000f};
static const struct bitmap_data testdata_32bppGrayFloat_xp = {
- &GUID_WICPixelFormat32bppGrayFloat, 32, (const BYTE *)bits_32bppGrayFloat_xp, 4, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat32bppGrayFloat, 32, (const BYTE *)bits_32bppGrayFloat_xp, 32, 2, 96.0, 96.0};
static const float bits_32bppGrayFloat[] = {
- 0.072200f,0.715200f,0.212600f,0.000000f,
- 0.927800f,0.284800f,0.787400f,1.000000f};
+ 0.072200f,0.715200f,0.212600f,0.000000f,0.072200f,0.715200f,0.212600f,0.000000f,
+ 0.072200f,0.715200f,0.212600f,0.000000f,0.072200f,0.715200f,0.212600f,0.000000f,
+ 0.072200f,0.715200f,0.212600f,0.000000f,0.072200f,0.715200f,0.212600f,0.000000f,
+ 0.072200f,0.715200f,0.212600f,0.000000f,0.072200f,0.715200f,0.212600f,0.000000f,
+ 0.927800f,0.284800f,0.787400f,1.000000f,0.927800f,0.284800f,0.787400f,1.000000f,
+ 0.927800f,0.284800f,0.787400f,1.000000f,0.927800f,0.284800f,0.787400f,1.000000f,
+ 0.927800f,0.284800f,0.787400f,1.000000f,0.927800f,0.284800f,0.787400f,1.000000f,
+ 0.927800f,0.284800f,0.787400f,1.000000f,0.927800f,0.284800f,0.787400f,1.000000f};
static const struct bitmap_data testdata_32bppGrayFloat = {
- &GUID_WICPixelFormat32bppGrayFloat, 32, (const BYTE *)bits_32bppGrayFloat, 4, 2, 96.0, 96.0, &testdata_32bppGrayFloat_xp};
+ &GUID_WICPixelFormat32bppGrayFloat, 32, (const BYTE *)bits_32bppGrayFloat, 32, 2, 96.0, 96.0, &testdata_32bppGrayFloat_xp};
static const BYTE bits_8bppGray_xp[] = {
- 29,150,76,0,
- 226,105,179,255};
+ 29,150,76,0,29,150,76,0,29,150,76,0,29,150,76,0,
+ 29,150,76,0,29,150,76,0,29,150,76,0,29,150,76,0,
+ 226,105,179,255,226,105,179,255,226,105,179,255,226,105,179,255,
+ 226,105,179,255,226,105,179,255,226,105,179,255,226,105,179,255};
static const struct bitmap_data testdata_8bppGray_xp = {
- &GUID_WICPixelFormat8bppGray, 8, bits_8bppGray_xp, 4, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat8bppGray, 8, bits_8bppGray_xp, 32, 2, 96.0, 96.0};
static const BYTE bits_8bppGray[] = {
- 76,220,127,0,
- 247,145,230,255};
+ 76,220,127,0,76,220,127,0,76,220,127,0,76,220,127,0,
+ 76,220,127,0,76,220,127,0,76,220,127,0,76,220,127,0,
+ 247,145,230,255,247,145,230,255,247,145,230,255,247,145,230,255,
+ 247,145,230,255,247,145,230,255,247,145,230,255,247,145,230,255};
static const struct bitmap_data testdata_8bppGray = {
- &GUID_WICPixelFormat8bppGray, 8, bits_8bppGray, 4, 2, 96.0, 96.0, &testdata_8bppGray_xp};
+ &GUID_WICPixelFormat8bppGray, 8, bits_8bppGray, 32, 2, 96.0, 96.0, &testdata_8bppGray_xp};
static const BYTE bits_24bppBGR_gray[] = {
- 76,76,76, 220,220,220, 127,127,127, 0,0,0,
- 247,247,247, 145,145,145, 230,230,230, 255,255,255};
+ 76,76,76, 220,220,220, 127,127,127, 0,0,0, 76,76,76, 220,220,220, 127,127,127, 0,0,0,
+ 76,76,76, 220,220,220, 127,127,127, 0,0,0, 76,76,76, 220,220,220, 127,127,127, 0,0,0,
+ 76,76,76, 220,220,220, 127,127,127, 0,0,0, 76,76,76, 220,220,220, 127,127,127, 0,0,0,
+ 76,76,76, 220,220,220, 127,127,127, 0,0,0, 76,76,76, 220,220,220, 127,127,127, 0,0,0,
+ 247,247,247, 145,145,145, 230,230,230, 255,255,255, 247,247,247, 145,145,145, 230,230,230, 255,255,255,
+ 247,247,247, 145,145,145, 230,230,230, 255,255,255, 247,247,247, 145,145,145, 230,230,230, 255,255,255,
+ 247,247,247, 145,145,145, 230,230,230, 255,255,255, 247,247,247, 145,145,145, 230,230,230, 255,255,255,
+ 247,247,247, 145,145,145, 230,230,230, 255,255,255, 247,247,247, 145,145,145, 230,230,230, 255,255,255};
static const struct bitmap_data testdata_24bppBGR_gray = {
- &GUID_WICPixelFormat24bppBGR, 24, bits_24bppBGR_gray, 4, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat24bppBGR, 24, bits_24bppBGR_gray, 32, 2, 96.0, 96.0};
static void test_conversion(const struct bitmap_data *src, const struct bitmap_data *dst, const char *name, BOOL todo)
{
@@ -398,11 +514,12 @@ static void test_conversion(const struct bitmap_data *src, const struct bitmap_d
hr = WICConvertBitmapSource(dst->format, &src_obj->IWICBitmapSource_iface, &dst_bitmap);
todo_wine_if (todo)
- ok(SUCCEEDED(hr), "WICConvertBitmapSource(%s) failed, hr=%x\n", name, hr);
+ ok(hr == S_OK ||
+ broken(hr == E_INVALIDARG) /* XP */, "WICConvertBitmapSource(%s) failed, hr=%x\n", name, hr);
- if (SUCCEEDED(hr))
+ if (hr == S_OK)
{
- compare_bitmap_data(dst, dst_bitmap, name);
+ compare_bitmap_data(src, dst, dst_bitmap, name);
IWICBitmapSource_Release(dst_bitmap);
}
@@ -450,7 +567,7 @@ static void test_default_converter(void)
ok(SUCCEEDED(hr), "Initialize returned %x\n", hr);
if (SUCCEEDED(hr))
- compare_bitmap_data(&testdata_32bppBGR, (IWICBitmapSource*)converter, "default converter");
+ compare_bitmap_data(&testdata_32bppBGRA, &testdata_32bppBGR, (IWICBitmapSource*)converter, "default converter");
IWICFormatConverter_Release(converter);
}
@@ -706,7 +823,7 @@ static void check_tiff_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat2bppIndexed))
{
- ok(width == 16, "wrong width %u\n", width);
+ ok(width == 32, "wrong width %u\n", width);
ok(height == 2, "wrong height %u\n", height);
ok(bps == 2, "wrong bps %d\n", bps);
@@ -716,7 +833,7 @@ static void check_tiff_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat4bppIndexed))
{
- ok(width == 8, "wrong width %u\n", width);
+ ok(width == 32, "wrong width %u\n", width);
ok(height == 2, "wrong height %u\n", height);
ok(bps == 4, "wrong bps %d\n", bps);
@@ -726,7 +843,7 @@ static void check_tiff_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat8bppIndexed))
{
- ok(width == 4, "wrong width %u\n", width);
+ ok(width == 32, "wrong width %u\n", width);
ok(height == 2, "wrong height %u\n", height);
ok(bps == 8, "wrong bps %d\n", bps);
@@ -736,7 +853,7 @@ static void check_tiff_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat24bppBGR))
{
- ok(width == 4, "wrong width %u\n", width);
+ ok(width == 32, "wrong width %u\n", width);
ok(height == 2, "wrong height %u\n", height);
ok(bps == 3, "wrong bps %d\n", bps);
@@ -754,7 +871,6 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
BITMAPFILEHEADER bfh;
BITMAPV5HEADER bih;
- memset(&bfh, 0, sizeof(bfh));
hr = IStream_Read(stream, &bfh, sizeof(bfh), NULL);
ok(hr == S_OK, "IStream_Read error %#x\n", hr);
@@ -762,13 +878,12 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
ok(bfh.bfReserved1 == 0, "wrong bfReserved1 %02x\n", bfh.bfReserved1);
ok(bfh.bfReserved2 == 0, "wrong bfReserved2 %02x\n", bfh.bfReserved2);
- memset(&bih, 0, sizeof(bih));
hr = IStream_Read(stream, &bih, sizeof(bih), NULL);
ok(hr == S_OK, "IStream_Read error %#x\n", hr);
if (IsEqualGUID(format, &GUID_WICPixelFormat1bppIndexed))
{
- ok(bfh.bfOffBits == 0x0436, "wrong bfOffBits %02x\n", bfh.bfOffBits);
+ ok(bfh.bfOffBits == 0x0436, "wrong bfOffBits %08x\n", bfh.bfOffBits);
ok(bih.bV5Width == 32, "wrong width %u\n", bih.bV5Width);
ok(bih.bV5Height == 2, "wrong height %u\n", bih.bV5Height);
@@ -780,9 +895,9 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat2bppIndexed))
{
- ok(bfh.bfOffBits == 0x0436, "wrong bfOffBits %02x\n", bfh.bfOffBits);
+ ok(bfh.bfOffBits == 0x0436, "wrong bfOffBits %08x\n", bfh.bfOffBits);
- ok(bih.bV5Width == 16, "wrong width %u\n", bih.bV5Width);
+ ok(bih.bV5Width == 32, "wrong width %u\n", bih.bV5Width);
ok(bih.bV5Height == 2, "wrong height %u\n", bih.bV5Height);
ok(bih.bV5Planes == 1, "wrong Planes %d\n", bih.bV5Planes);
@@ -792,9 +907,9 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat4bppIndexed))
{
- ok(bfh.bfOffBits == 0x0436, "wrong bfOffBits %02x\n", bfh.bfOffBits);
+ ok(bfh.bfOffBits == 0x0436, "wrong bfOffBits %08x\n", bfh.bfOffBits);
- ok(bih.bV5Width == 8, "wrong width %u\n", bih.bV5Width);
+ ok(bih.bV5Width == 32, "wrong width %u\n", bih.bV5Width);
ok(bih.bV5Height == 2, "wrong height %u\n", bih.bV5Height);
ok(bih.bV5Planes == 1, "wrong Planes %d\n", bih.bV5Planes);
@@ -804,9 +919,9 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat8bppIndexed))
{
- ok(bfh.bfOffBits == 0x0436, "wrong bfOffBits %02x\n", bfh.bfOffBits);
+ ok(bfh.bfOffBits == 0x0436, "wrong bfOffBits %08x\n", bfh.bfOffBits);
- ok(bih.bV5Width == 4, "wrong width %u\n", bih.bV5Width);
+ ok(bih.bV5Width == 32, "wrong width %u\n", bih.bV5Width);
ok(bih.bV5Height == 2, "wrong height %u\n", bih.bV5Height);
ok(bih.bV5Planes == 1, "wrong Planes %d\n", bih.bV5Planes);
@@ -816,9 +931,9 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat32bppBGR))
{
- ok(bfh.bfOffBits == 0x0036, "wrong bfOffBits %02x\n", bfh.bfOffBits);
+ ok(bfh.bfOffBits == 0x0036, "wrong bfOffBits %08x\n", bfh.bfOffBits);
- ok(bih.bV5Width == 4, "wrong width %u\n", bih.bV5Width);
+ ok(bih.bV5Width == 32, "wrong width %u\n", bih.bV5Width);
ok(bih.bV5Height == 2, "wrong height %u\n", bih.bV5Height);
ok(bih.bV5Planes == 1, "wrong Planes %d\n", bih.bV5Planes);
@@ -886,7 +1001,7 @@ static void check_png_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat2bppIndexed))
{
- ok(be_uint(png.width) == 16, "wrong width %u\n", be_uint(png.width));
+ ok(be_uint(png.width) == 32, "wrong width %u\n", be_uint(png.width));
ok(be_uint(png.height) == 2, "wrong height %u\n", be_uint(png.height));
ok(png.bit_depth == 2, "wrong bit_depth %d\n", png.bit_depth);
@@ -897,7 +1012,7 @@ static void check_png_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat4bppIndexed))
{
- ok(be_uint(png.width) == 8, "wrong width %u\n", be_uint(png.width));
+ ok(be_uint(png.width) == 32, "wrong width %u\n", be_uint(png.width));
ok(be_uint(png.height) == 2, "wrong height %u\n", be_uint(png.height));
ok(png.bit_depth == 4, "wrong bit_depth %d\n", png.bit_depth);
@@ -908,7 +1023,7 @@ static void check_png_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat8bppIndexed))
{
- ok(be_uint(png.width) == 4, "wrong width %u\n", be_uint(png.width));
+ ok(be_uint(png.width) == 32, "wrong width %u\n", be_uint(png.width));
ok(be_uint(png.height) == 2, "wrong height %u\n", be_uint(png.height));
ok(png.bit_depth == 8, "wrong bit_depth %d\n", png.bit_depth);
@@ -919,7 +1034,7 @@ static void check_png_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat24bppBGR))
{
- ok(be_uint(png.width) == 4, "wrong width %u\n", be_uint(png.width));
+ ok(be_uint(png.width) == 32, "wrong width %u\n", be_uint(png.width));
ok(be_uint(png.height) == 2, "wrong height %u\n", be_uint(png.height));
ok(png.bit_depth == 8, "wrong bit_depth %d\n", png.bit_depth);
@@ -1054,8 +1169,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) ||
- broken(IsEqualGUID(clsid_encoder, &CLSID_WICTiffEncoder) && srcs[i]->bpp == 2 && IsEqualGUID(&pixelformat, &GUID_WICPixelFormat4bppIndexed)) ||
- broken(IsEqualGUID(clsid_encoder, &CLSID_WICBmpEncoder) && srcs[i]->bpp == 2 && IsEqualGUID(&pixelformat, &GUID_WICPixelFormat4bppIndexed)),
+ broken(IsEqualGUID(clsid_encoder, &CLSID_WICBmpEncoder) && srcs[i]->bpp == 2 && IsEqualGUID(&pixelformat, &GUID_WICPixelFormat4bppIndexed)) ||
+ broken(IsEqualGUID(clsid_encoder, &CLSID_WICTiffEncoder) && srcs[i]->bpp == 2 && IsEqualGUID(&pixelformat, &GUID_WICPixelFormat4bppIndexed)),
"SetPixelFormat changed the format to %s (%s)\n", wine_dbgstr_guid(&pixelformat), name);
hr = IWICBitmapFrameEncode_SetSize(frameencode, srcs[i]->width, srcs[i]->height);
@@ -1088,8 +1203,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 ||
- broken(hr == E_NOTIMPL && IsEqualGUID(clsid_encoder, &CLSID_WICBmpEncoder) && srcs[i]->bpp == 2) ||
- broken(hr == E_NOTIMPL && IsEqualGUID(clsid_encoder, &CLSID_WICTiffEncoder) && srcs[i]->bpp == 2) ||
+ broken(hr == E_INVALIDARG && IsEqualGUID(clsid_encoder, &CLSID_WICBmpEncoder) && srcs[i]->bpp == 2) /* XP */ ||
+ broken(hr == E_INVALIDARG && IsEqualGUID(clsid_encoder, &CLSID_WICTiffEncoder) && srcs[i]->bpp == 2) /* XP */ ||
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);
}
@@ -1114,7 +1229,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);
- check_bitmap_format(stream, clsid_encoder, dsts[0]->format);
+ if (IsEqualGUID(&pixelformat, dsts[0]->format))
+ check_bitmap_format(stream, clsid_encoder, dsts[0]->format);
}
if (SUCCEEDED(hr))
@@ -1149,7 +1265,9 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
if (SUCCEEDED(hr))
{
- compare_bitmap_data(dsts[i], (IWICBitmapSource*)framedecode, name);
+ hr = IWICBitmapFrameDecode_GetPixelFormat(framedecode, &pixelformat);
+ if (IsEqualGUID(&pixelformat, dsts[i]->format))
+ compare_bitmap_data(srcs[i], dsts[i], (IWICBitmapSource*)framedecode, name);
hr = IWICBitmapFrameDecode_CopyPalette(framedecode, frame_palette);
if (winetest_debug > 1)
@@ -1197,8 +1315,8 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
else if (IsEqualGUID(clsid_decoder, &CLSID_WICBmpDecoder) ||
IsEqualGUID(clsid_decoder, &CLSID_WICTiffDecoder))
{
- if (IsEqualGUID(dsts[i]->format, &GUID_WICPixelFormatBlackWhite) ||
- IsEqualGUID(dsts[i]->format, &GUID_WICPixelFormat8bppIndexed))
+ if (IsEqualGUID(&pixelformat, &GUID_WICPixelFormatBlackWhite) ||
+ IsEqualGUID(&pixelformat, &GUID_WICPixelFormat8bppIndexed))
{
ok(count == 256, "expected 256, got %u (%s)\n", count, name);
@@ -1209,7 +1327,7 @@ 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);
}
- else if (IsEqualGUID(dsts[i]->format, &GUID_WICPixelFormat2bppIndexed))
+ else if (IsEqualGUID(&pixelformat, &GUID_WICPixelFormat2bppIndexed))
{
ok(count == 4, "expected 4, got %u (%s)\n", count, name);
@@ -1218,7 +1336,7 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
ok(colors[2] == 0xff333333, "got %08x (%s)\n", colors[2], name);
ok(colors[3] == 0xff444444, "got %08x (%s)\n", colors[3], name);
}
- else if (IsEqualGUID(dsts[i]->format, &GUID_WICPixelFormat4bppIndexed))
+ else if (IsEqualGUID(&pixelformat, &GUID_WICPixelFormat4bppIndexed))
{
ok(count == 16, "expected 16, got %u (%s)\n", count, name);
@@ -1308,7 +1426,7 @@ static void test_encoder_rects(void)
rc.X = 0;
rc.Y = 0;
- rc.Width = 4;
+ rc.Width = 32;
rc.Height = 2;
test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects full", NULL);
@@ -1319,7 +1437,7 @@ static void test_encoder_rects(void)
rc.Width = -1;
test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects width=-1", NULL);
- rc.Width = 4;
+ rc.Width = 32;
rc.Height = 0;
test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects height=0", NULL);
@@ -1351,6 +1469,16 @@ START_TEST(converter)
&IID_IWICImagingFactory, (void **)&factory);
ok(hr == S_OK, "failed to create factory: %#x\n", hr);
+ test_conversion(&testdata_24bppRGB, &testdata_2bppIndexed, "24bppRGB -> 1bppIndexed", TRUE);
+ test_conversion(&testdata_24bppRGB, &testdata_2bppIndexed, "24bppRGB -> 2bppIndexed", TRUE);
+ test_conversion(&testdata_24bppRGB, &testdata_4bppIndexed, "24bppRGB -> 4bppIndexed", TRUE);
+ test_conversion(&testdata_24bppRGB, &testdata_8bppIndexed, "24bppRGB -> 8bppIndexed", FALSE);
+
+ test_conversion(&testdata_BlackWhite, &testdata_8bppIndexed_BW, "BlackWhite -> 8bppIndexed", TRUE);
+ test_conversion(&testdata_1bppIndexed, &testdata_8bppIndexed_BW, "1bppIndexed -> 8bppIndexed", TRUE);
+ test_conversion(&testdata_2bppIndexed, &testdata_8bppIndexed_4colors, "2bppIndexed -> 8bppIndexed", TRUE);
+ test_conversion(&testdata_4bppIndexed, &testdata_8bppIndexed, "4bppIndexed -> 8bppIndexed", TRUE);
+
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);
@@ -1388,6 +1516,11 @@ START_TEST(converter)
&testdata_8bppIndexed, &CLSID_WICPngDecoder, "PNG encoder 8bppIndexed");
test_encoder(&testdata_24bppBGR, &CLSID_WICPngEncoder,
&testdata_24bppBGR, &CLSID_WICPngDecoder, "PNG encoder 24bppBGR");
+if (!strcmp(winetest_platform, "windows")) /* FIXME: enable once implemented in Wine */
+{
+ test_encoder(&testdata_32bppBGR, &CLSID_WICPngEncoder,
+ &testdata_24bppBGR, &CLSID_WICPngDecoder, "PNG encoder 32bppBGR");
+}
test_encoder(&testdata_BlackWhite, &CLSID_WICBmpEncoder,
&testdata_1bppIndexed, &CLSID_WICBmpDecoder, "BMP encoder BlackWhite");
--
2.9.0

View File

@ -0,0 +1,190 @@
From cf2301cafab21d7a67cf7a3b3a11db0ed17d0042 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 27 Oct 2016 15:13:24 +0800
Subject: windowscodecs/tests: Add some tests for converting 24bppBGR to
8bppIndexed format.
---
dlls/windowscodecs/tests/converter.c | 159 +++++++++++++++++++++++++++++++++++
1 file changed, 159 insertions(+)
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c
index e6d21ac..b8ed4d4 100644
--- a/dlls/windowscodecs/tests/converter.c
+++ b/dlls/windowscodecs/tests/converter.c
@@ -1459,6 +1459,163 @@ static const struct setting png_interlace_settings[] = {
{NULL}
};
+static void test_converter_8bppIndexed(void)
+{
+ HRESULT hr;
+ BitmapTestSrc *src_obj;
+ IWICFormatConverter *converter;
+ IWICPalette *palette;
+ UINT count, i;
+ BYTE buf[32 * 2 * 3]; /* enough to hold 32x2 24bppBGR data */
+
+ CreateTestBitmap(&testdata_24bppBGR, &src_obj);
+
+ hr = IWICImagingFactory_CreatePalette(factory, &palette);
+ ok(hr == S_OK, "CreatePalette error %#x\n", hr);
+ count = 0xdeadbeef;
+ hr = IWICPalette_GetColorCount(palette, &count);
+ ok(hr == S_OK, "GetColorCount error %#x\n", hr);
+ ok(count == 0, "expected 0, got %u\n", count);
+
+ /* NULL palette + Custom type*/
+ hr = IWICImagingFactory_CreateFormatConverter(factory, &converter);
+ ok(hr == S_OK, "CreateFormatConverter error %#x\n", hr);
+ hr = IWICFormatConverter_Initialize(converter, &src_obj->IWICBitmapSource_iface,
+ &GUID_WICPixelFormat24bppBGR, WICBitmapDitherTypeNone,
+ NULL, 0.0, WICBitmapPaletteTypeCustom);
+ ok(hr == S_OK, "Initialize error %#x\n", hr);
+ hr = IWICFormatConverter_CopyPalette(converter, palette);
+ ok(hr == 0xdeadbeef, "unexpected error %#x\n", hr);
+ hr = IWICFormatConverter_CopyPixels(converter, NULL, 32 * 3, sizeof(buf), buf);
+ ok(hr == S_OK, "CopyPixels error %#x\n", hr);
+ IWICFormatConverter_Release(converter);
+
+ /* NULL palette + Custom type*/
+ hr = IWICImagingFactory_CreateFormatConverter(factory, &converter);
+ ok(hr == S_OK, "CreateFormatConverter error %#x\n", hr);
+ hr = IWICFormatConverter_Initialize(converter, &src_obj->IWICBitmapSource_iface,
+ &GUID_WICPixelFormat8bppIndexed, WICBitmapDitherTypeNone,
+ NULL, 0.0, WICBitmapPaletteTypeCustom);
+ ok(hr == E_INVALIDARG, "unexpected error %#x\n", hr);
+ hr = IWICFormatConverter_CopyPalette(converter, palette);
+ ok(hr == WINCODEC_ERR_WRONGSTATE, "unexpected error %#x\n", hr);
+ hr = IWICFormatConverter_CopyPixels(converter, NULL, 32, sizeof(buf), buf);
+ ok(hr == WINCODEC_ERR_WRONGSTATE, "unexpected error %#x\n", hr);
+ IWICFormatConverter_Release(converter);
+
+ /* empty palette + Custom type*/
+ hr = IWICImagingFactory_CreateFormatConverter(factory, &converter);
+ ok(hr == S_OK, "CreateFormatConverter error %#x\n", hr);
+ hr = IWICFormatConverter_Initialize(converter, &src_obj->IWICBitmapSource_iface,
+ &GUID_WICPixelFormat8bppIndexed, WICBitmapDitherTypeNone,
+ palette, 0.0, WICBitmapPaletteTypeCustom);
+ ok(hr == S_OK, "Initialize error %#x\n", hr);
+ hr = IWICFormatConverter_CopyPalette(converter, palette);
+ ok(hr == S_OK, "CopyPalette error %#x\n", hr);
+ count = 0xdeadbeef;
+ hr = IWICPalette_GetColorCount(palette, &count);
+ ok(hr == S_OK, "GetColorCount error %#x\n", hr);
+ ok(count == 0, "expected 0, got %u\n", count);
+ memset(buf, 0xaa, sizeof(buf));
+ hr = IWICFormatConverter_CopyPixels(converter, NULL, 32, sizeof(buf), buf);
+ ok(hr == S_OK, "CopyPixels error %#x\n", hr);
+ count = 0;
+ for (i = 0; i < 32 * 2; i++)
+ if (buf[i] != 0) count++;
+ ok(count == 0, "expected 0\n");
+ IWICFormatConverter_Release(converter);
+
+ /* NULL palette + Predefined type*/
+ hr = IWICImagingFactory_CreateFormatConverter(factory, &converter);
+ ok(hr == S_OK, "CreateFormatConverter error %#x\n", hr);
+ hr = IWICFormatConverter_Initialize(converter, &src_obj->IWICBitmapSource_iface,
+ &GUID_WICPixelFormat8bppIndexed, WICBitmapDitherTypeNone,
+ NULL, 0.0, WICBitmapPaletteTypeFixedGray16);
+ ok(hr == S_OK, "Initialize error %#x\n", hr);
+ hr = IWICFormatConverter_CopyPalette(converter, palette);
+ ok(hr == S_OK, "CopyPalette error %#x\n", hr);
+ count = 0xdeadbeef;
+ hr = IWICPalette_GetColorCount(palette, &count);
+ ok(hr == S_OK, "GetColorCount error %#x\n", hr);
+ ok(count == 16, "expected 16, got %u\n", count);
+ hr = IWICFormatConverter_CopyPixels(converter, NULL, 32, sizeof(buf), buf);
+ ok(hr == S_OK, "CopyPixels error %#x\n", hr);
+ count = 0;
+ for (i = 0; i < 32 * 2; i++)
+ if (buf[i] != 0) count++;
+ ok(count != 0, "expected != 0\n");
+ IWICFormatConverter_Release(converter);
+
+ /* not empty palette + Predefined type*/
+ hr = IWICImagingFactory_CreateFormatConverter(factory, &converter);
+ ok(hr == S_OK, "CreateFormatConverter error %#x\n", hr);
+ hr = IWICFormatConverter_Initialize(converter, &src_obj->IWICBitmapSource_iface,
+ &GUID_WICPixelFormat8bppIndexed, WICBitmapDitherTypeNone,
+ palette, 0.0, WICBitmapPaletteTypeFixedHalftone64);
+ ok(hr == S_OK, "Initialize error %#x\n", hr);
+ hr = IWICFormatConverter_CopyPalette(converter, palette);
+ ok(hr == S_OK, "CopyPalette error %#x\n", hr);
+ count = 0xdeadbeef;
+ hr = IWICPalette_GetColorCount(palette, &count);
+ ok(hr == S_OK, "GetColorCount error %#x\n", hr);
+ ok(count == 16, "expected 16, got %u\n", count);
+ hr = IWICFormatConverter_CopyPixels(converter, NULL, 32, sizeof(buf), buf);
+ ok(hr == S_OK, "CopyPixels error %#x\n", hr);
+ count = 0;
+ for (i = 0; i < 32 * 2; i++)
+ if (buf[i] != 0) count++;
+ ok(count != 0, "expected != 0\n");
+ IWICFormatConverter_Release(converter);
+
+ /* not empty palette + MedianCut type*/
+ hr = IWICImagingFactory_CreateFormatConverter(factory, &converter);
+ ok(hr == S_OK, "CreateFormatConverter error %#x\n", hr);
+ hr = IWICFormatConverter_Initialize(converter, &src_obj->IWICBitmapSource_iface,
+ &GUID_WICPixelFormat8bppIndexed, WICBitmapDitherTypeNone,
+ palette, 0.0, WICBitmapPaletteTypeMedianCut);
+ ok(hr == S_OK, "Initialize error %#x\n", hr);
+ hr = IWICFormatConverter_CopyPalette(converter, palette);
+ ok(hr == S_OK, "CopyPalette error %#x\n", hr);
+ count = 0xdeadbeef;
+ hr = IWICPalette_GetColorCount(palette, &count);
+ ok(hr == S_OK, "GetColorCount error %#x\n", hr);
+ ok(count == 16, "expected 16, got %u\n", count);
+ hr = IWICFormatConverter_CopyPixels(converter, NULL, 32, sizeof(buf), buf);
+ ok(hr == S_OK, "CopyPixels error %#x\n", hr);
+ count = 0;
+ for (i = 0; i < 32 * 2; i++)
+ if (buf[i] != 0) count++;
+ ok(count != 0, "expected != 0\n");
+ IWICFormatConverter_Release(converter);
+
+ /* NULL palette + MedianCut type*/
+ hr = IWICImagingFactory_CreateFormatConverter(factory, &converter);
+ ok(hr == S_OK, "CreateFormatConverter error %#x\n", hr);
+ hr = IWICFormatConverter_Initialize(converter, &src_obj->IWICBitmapSource_iface,
+ &GUID_WICPixelFormat8bppIndexed, WICBitmapDitherTypeNone,
+ NULL, 0.0, WICBitmapPaletteTypeMedianCut);
+ ok(hr == S_OK || broken(hr == E_INVALIDARG) /* XP */, "Initialize error %#x\n", hr);
+ if (hr == S_OK)
+ {
+ hr = IWICFormatConverter_CopyPalette(converter, palette);
+ ok(hr == S_OK, "CopyPalette error %#x\n", hr);
+ count = 0xdeadbeef;
+ hr = IWICPalette_GetColorCount(palette, &count);
+ ok(hr == S_OK, "GetColorCount error %#x\n", hr);
+ ok(count == 8, "expected 8, got %u\n", count);
+ hr = IWICFormatConverter_CopyPixels(converter, NULL, 32, sizeof(buf), buf);
+ ok(hr == S_OK, "CopyPixels error %#x\n", hr);
+ count = 0;
+ for (i = 0; i < 32 * 2; i++)
+ if (buf[i] != 0) count++;
+ ok(count != 0, "expected != 0\n");
+ }
+ IWICFormatConverter_Release(converter);
+
+ IWICPalette_Release(palette);
+ DeleteTestBitmap(src_obj);
+}
+
START_TEST(converter)
{
HRESULT hr;
@@ -1469,6 +1626,8 @@ START_TEST(converter)
&IID_IWICImagingFactory, (void **)&factory);
ok(hr == S_OK, "failed to create factory: %#x\n", hr);
+ test_converter_8bppIndexed();
+
test_conversion(&testdata_24bppRGB, &testdata_2bppIndexed, "24bppRGB -> 1bppIndexed", TRUE);
test_conversion(&testdata_24bppRGB, &testdata_2bppIndexed, "24bppRGB -> 2bppIndexed", TRUE);
test_conversion(&testdata_24bppRGB, &testdata_4bppIndexed, "24bppRGB -> 4bppIndexed", TRUE);
--
2.9.0

View File

@ -0,0 +1,129 @@
From e90eb83510bd3edbdc8ca8984cb9d0643b652fa1 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 27 Oct 2016 15:17:19 +0800
Subject: windowscodecs/tests: Add the tests for GIF encoder and decoder.
---
dlls/windowscodecs/tests/converter.c | 59 +++++++++++++++++++++++++++++++++---
1 file changed, 54 insertions(+), 5 deletions(-)
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c
index b8ed4d4..430c0ed 100644
--- a/dlls/windowscodecs/tests/converter.c
+++ b/dlls/windowscodecs/tests/converter.c
@@ -1047,6 +1047,40 @@ 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_gif_format(IStream *stream, const WICPixelFormatGUID *format)
+{
+#include "pshpack1.h"
+ struct logical_screen_descriptor
+ {
+ char signature[6];
+ USHORT width;
+ USHORT height;
+ BYTE packed;
+ /* global_color_table_flag : 1;
+ * color_resolution : 3;
+ * sort_flag : 1;
+ * global_color_table_size : 3;
+ */
+ BYTE background_color_index;
+ BYTE pixel_aspect_ratio;
+ } lsd;
+#include "poppack.h"
+ UINT color_resolution;
+ HRESULT hr;
+
+ memset(&lsd, 0, sizeof(lsd));
+ hr = IStream_Read(stream, &lsd, sizeof(lsd), NULL);
+ ok(hr == S_OK, "IStream_Read error %#x\n", hr);
+
+ ok(!memcmp(lsd.signature, "GIF89a", 6), "wrong GIF signature %.6s\n", lsd.signature);
+
+ ok(lsd.width == 32, "wrong width %u\n", lsd.width);
+ ok(lsd.height == 2, "wrong height %u\n", lsd.height);
+ color_resolution = 1 << (((lsd.packed >> 4) & 0x07) + 1);
+ ok(color_resolution == 256, "wrong color resolution %u\n", color_resolution);
+ ok(lsd.pixel_aspect_ratio == 0, "wrong pixel_aspect_ratio %u\n", lsd.pixel_aspect_ratio);
+}
+
static void check_bitmap_format(IStream *stream, const CLSID *encoder, const WICPixelFormatGUID *format)
{
HRESULT hr;
@@ -1062,6 +1096,8 @@ static void check_bitmap_format(IStream *stream, const CLSID *encoder, const WIC
check_bmp_format(stream, format);
else if (IsEqualGUID(encoder, &CLSID_WICTiffEncoder))
check_tiff_format(stream, format);
+ else if (IsEqualGUID(encoder, &CLSID_WICGifEncoder))
+ check_gif_format(stream, format);
else
ok(0, "unknown encoder %s\n", wine_dbgstr_guid(encoder));
@@ -1094,7 +1130,7 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
hr = CoCreateInstance(clsid_encoder, NULL, CLSCTX_INPROC_SERVER,
&IID_IWICBitmapEncoder, (void**)&encoder);
- ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
+ ok(SUCCEEDED(hr), "CoCreateInstance(%s) failed, hr=%x\n", wine_dbgstr_guid(clsid_encoder), hr);
if (SUCCEEDED(hr))
{
hglobal = GlobalAlloc(GMEM_MOVEABLE, 0);
@@ -1119,7 +1155,10 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
if (palette)
{
hr = IWICBitmapEncoder_SetPalette(encoder, palette);
- ok(hr == WINCODEC_ERR_UNSUPPORTEDOPERATION, "wrong error %#x\n", hr);
+ if (IsEqualGUID(clsid_encoder, &CLSID_WICGifEncoder))
+ ok(hr == S_OK, "SetPalette failed, hr=%#x\n", hr);
+ else
+ ok(hr == WINCODEC_ERR_UNSUPPORTEDOPERATION, "wrong error %#x\n", hr);
hr = S_OK;
}
@@ -1248,13 +1287,19 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
ok(hr == S_OK, "CreatePalette error %#x\n", hr);
hr = IWICBitmapDecoder_CopyPalette(decoder, frame_palette);
- ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "wrong error %#x\n", hr);
+ if (IsEqualGUID(clsid_decoder, &CLSID_WICGifDecoder))
+ ok(hr == WINCODEC_ERR_WRONGSTATE, "wrong error %#x\n", hr);
+ else
+ ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "wrong error %#x\n", hr);
hr = IWICBitmapDecoder_Initialize(decoder, stream, WICDecodeMetadataCacheOnDemand);
ok(SUCCEEDED(hr), "Initialize failed, hr=%x\n", hr);
hr = IWICBitmapDecoder_CopyPalette(decoder, frame_palette);
- ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "wrong error %#x\n", hr);
+ if (IsEqualGUID(clsid_decoder, &CLSID_WICGifDecoder))
+ ok(hr == S_OK || broken(hr == WINCODEC_ERR_FRAMEMISSING) /* XP */, "CopyPalette failed, hr=%#x\n", hr);
+ else
+ ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "wrong error %#x\n", hr);
hr = S_OK;
i=0;
@@ -1313,7 +1358,8 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
}
}
else if (IsEqualGUID(clsid_decoder, &CLSID_WICBmpDecoder) ||
- IsEqualGUID(clsid_decoder, &CLSID_WICTiffDecoder))
+ IsEqualGUID(clsid_decoder, &CLSID_WICTiffDecoder) ||
+ IsEqualGUID(clsid_decoder, &CLSID_WICGifDecoder))
{
if (IsEqualGUID(&pixelformat, &GUID_WICPixelFormatBlackWhite) ||
IsEqualGUID(&pixelformat, &GUID_WICPixelFormat8bppIndexed))
@@ -1663,6 +1709,9 @@ START_TEST(converter)
test_invalid_conversion();
test_default_converter();
+ test_encoder(&testdata_8bppIndexed, &CLSID_WICGifEncoder,
+ &testdata_8bppIndexed, &CLSID_WICGifDecoder, "GIF encoder 8bppIndexed");
+
test_encoder(&testdata_BlackWhite, &CLSID_WICPngEncoder,
&testdata_BlackWhite, &CLSID_WICPngDecoder, "PNG encoder BlackWhite");
test_encoder(&testdata_1bppIndexed, &CLSID_WICPngEncoder,
--
2.9.0

View File

@ -1 +1,2 @@
Fixes: Add initial implementation of GIF encoder to windowscodecs
Depends: windowscodecs-Palette_Images