Added patch for support of 8bpp grayscale TIFF images with 8bpp alpha channel (replaces previous stub).

This commit is contained in:
Sebastian Lackner 2015-04-01 03:14:19 +02:00
parent 168c9879a0
commit 7995c78fbf
6 changed files with 253 additions and 44 deletions

View File

@ -152,7 +152,6 @@ Included bug fixes and improvements
* Graphical issues in Inquisitor ([Wine Bug #32490](https://bugs.winehq.org/show_bug.cgi?id=32490))
* Hearthstone fails to start ([Wine Bug #36216](https://bugs.winehq.org/show_bug.cgi?id=36216))
* IOCTL_DVD_READ_STRUCTURE expects the wrong size of output buffer for some requests ([Wine Bug #37767](https://bugs.winehq.org/show_bug.cgi?id=37767))
* Ignore unsupported alpha channels in TIFF decoder ([Wine Bug #38027](https://bugs.winehq.org/show_bug.cgi?id=38027))
* Ignore unsupported flags for CoInternetSetFeatureEnabled ([Wine Bug #35197](https://bugs.winehq.org/show_bug.cgi?id=35197))
* Implement D3DXGetShaderOutputSemantics
* Implement ID3DXEffect::FindNextValidTechnique ([Wine Bug #34101](https://bugs.winehq.org/show_bug.cgi?id=34101))
@ -208,6 +207,7 @@ Included bug fixes and improvements
* Send WM_PAINT event during dialog creation ([Wine Bug #35652](https://bugs.winehq.org/show_bug.cgi?id=35652))
* Set last error when GetRawInputDeviceList fails ([Wine Bug #37667](https://bugs.winehq.org/show_bug.cgi?id=37667))
* Super Mario 3: Mario Forever fails to load keyboard mapping from profile files. ([Wine Bug #18099](https://bugs.winehq.org/show_bug.cgi?id=18099))
* Support for 8bpp grayscale TIFF images with 8bpp alpha channel ([Wine Bug #38027](https://bugs.winehq.org/show_bug.cgi?id=38027))
* Support for AllocateAndGetTcpExTableFromStack ([Wine Bug #34372](https://bugs.winehq.org/show_bug.cgi?id=34372))
* Support for BindImageEx ([Wine Bug #3591](https://bugs.winehq.org/show_bug.cgi?id=3591))
* Support for CSMT (command stream) to increase graphic performance ([Wine Bug #11674](https://bugs.winehq.org/show_bug.cgi?id=11674))

1
debian/changelog vendored
View File

@ -13,6 +13,7 @@ wine-staging (1.7.40) UNRELEASED; urgency=low
* Added patch to return correct device type for cd devices without medium.
* Added patch to fix device paths in HKLM\SYSTEM\MountedDevices.
* Added patch to show unmounted devices in winecfg and allow changing the unix path.
* Added patch for support of 8bpp grayscale TIFF images with 8bpp alpha channel (replaces previous stub).
* Removed patch to fix regression causing black screen on startup (accepted upstream).
* Removed patch to fix edge cases in TOOLTIPS_GetTipText (fixed upstream).
* Removed patch for IConnectionPoint/INetworkListManagerEvents stub interface (accepted upstream).

View File

@ -4362,15 +4362,15 @@ fi
# Patchset windowscodecs-TIFF_Decoder
# |
# | This patchset fixes the following Wine bugs:
# | * [#38027] Ignore unsupported alpha channels in TIFF decoder
# | * [#38027] Support for 8bpp grayscale TIFF images with 8bpp alpha channel
# |
# | Modified files:
# | * dlls/windowscodecs/tiffformat.c
# | * dlls/windowscodecs/tests/tiffformat.c, dlls/windowscodecs/tiffformat.c
# |
if test "$enable_windowscodecs_TIFF_Decoder" -eq 1; then
patch_apply windowscodecs-TIFF_Decoder/0001-windowscodecs-Ignore-unsupported-alpha-channel-in-ti.patch
patch_apply windowscodecs-TIFF_Decoder/0001-windowscodecs-Add-support-for-8bpp-grayscale-TIFF-im.patch
(
echo '+ { "Dmitry Timoshkov", "windowscodecs: Ignore unsupported alpha channel in tiff_get_decode_info.", 1 },';
echo '+ { "Dmitry Timoshkov", "windowscodecs: Add support for 8bpp grayscale TIFF images with 8bpp alpha channel.", 1 },';
) >> "$patchlist"
fi

View File

@ -0,0 +1,246 @@
From 62f8f2989fd6f2116fbd93ae9c7a6b9332c2cd77 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Wed, 1 Apr 2015 03:06:29 +0200
Subject: windowscodecs: Add support for 8bpp grayscale TIFF images with 8bpp
alpha channel.
---
dlls/windowscodecs/tests/tiffformat.c | 103 ++++++++++++++++++++++++++++++++++
dlls/windowscodecs/tiffformat.c | 66 ++++++++++++++++++++--
2 files changed, 164 insertions(+), 5 deletions(-)
diff --git a/dlls/windowscodecs/tests/tiffformat.c b/dlls/windowscodecs/tests/tiffformat.c
index cc1951e..d07caa3 100644
--- a/dlls/windowscodecs/tests/tiffformat.c
+++ b/dlls/windowscodecs/tests/tiffformat.c
@@ -92,6 +92,48 @@ static const struct tiff_1bpp_data
{ 900, 3 },
{ 0x11, 0x22, 0x33, 0 }
};
+
+static const struct tiff_8bpp_alpha
+{
+ USHORT byte_order;
+ USHORT version;
+ ULONG dir_offset;
+ USHORT number_of_entries;
+ struct IFD_entry entry[15];
+ ULONG next_IFD;
+ struct IFD_rational res;
+ BYTE pixel_data[8];
+} tiff_8bpp_alpha =
+{
+#ifdef WORDS_BIGENDIAN
+ 'M' | 'M' << 8,
+#else
+ 'I' | 'I' << 8,
+#endif
+ 42,
+ FIELD_OFFSET(struct tiff_8bpp_alpha, number_of_entries),
+ 15,
+ {
+ { 0xff, IFD_SHORT, 1, 0 }, /* SUBFILETYPE */
+ { 0x100, IFD_LONG, 1, 2 }, /* IMAGEWIDTH */
+ { 0x101, IFD_LONG, 1, 2 }, /* IMAGELENGTH */
+ { 0x102, IFD_SHORT, 2, MAKELONG(8, 8) }, /* BITSPERSAMPLE */
+ { 0x103, IFD_SHORT, 1, 1 }, /* COMPRESSION: XP doesn't accept IFD_LONG here */
+ { 0x106, IFD_SHORT, 1, 1 }, /* PHOTOMETRIC */
+ { 0x111, IFD_LONG, 1, FIELD_OFFSET(struct tiff_8bpp_alpha, pixel_data) }, /* STRIPOFFSETS */
+ { 0x115, IFD_SHORT, 1, 2 }, /* SAMPLESPERPIXEL */
+ { 0x116, IFD_LONG, 1, 2 }, /* ROWSPERSTRIP */
+ { 0x117, IFD_LONG, 1, 8 }, /* STRIPBYTECOUNT */
+ { 0x11a, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_8bpp_alpha, res) },
+ { 0x11b, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_8bpp_alpha, res) },
+ { 0x11c, IFD_SHORT, 1, 1 }, /* PLANARCONFIGURATION */
+ { 0x128, IFD_SHORT, 1, 2 }, /* RESOLUTIONUNIT */
+ { 0x152, IFD_SHORT, 1, 1 } /* EXTRASAMPLES: 1 - Associated alpha with pre-multiplied color */
+ },
+ 0,
+ { 96, 1 },
+ { 0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88 }
+};
#include "poppack.h"
static IWICImagingFactory *factory;
@@ -264,6 +306,66 @@ todo_wine
IStream_Release(stream);
}
+static void test_tiff_8bpp_alpha(void)
+{
+ HRESULT hr;
+ IWICBitmapDecoder *decoder;
+ IWICBitmapFrameDecode *frame;
+ UINT frame_count, width, height, i;
+ double dpi_x, dpi_y;
+ IWICPalette *palette;
+ GUID format;
+ WICRect rc;
+ BYTE data[16];
+ static const BYTE expected_data[16] = { 0x11,0x11,0x11,0x22,0x33,0x33,0x33,0x44,
+ 0x55,0x55,0x55,0x66,0x77,0x77,0x77,0x88 };
+
+ decoder = create_decoder(&tiff_8bpp_alpha, sizeof(tiff_8bpp_alpha));
+ ok(decoder != 0, "Failed to load TIFF image data\n");
+
+ hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
+ ok(hr == S_OK, "GetFrameCount error %#x\n", hr);
+ ok(frame_count == 1, "expected 1, got %u\n", frame_count);
+
+ hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
+ ok(hr == S_OK, "GetFrame error %#x\n", hr);
+
+ hr = IWICBitmapFrameDecode_GetSize(frame, &width, &height);
+ ok(hr == S_OK, "GetSize error %#x\n", hr);
+ ok(width == 2, "expected 2, got %u\n", width);
+ ok(height == 2, "expected 2, got %u\n", height);
+
+ hr = IWICBitmapFrameDecode_GetResolution(frame, &dpi_x, &dpi_y);
+ ok(hr == S_OK, "GetResolution error %#x\n", hr);
+ ok(dpi_x == 96.0, "expected 96.0, got %f\n", dpi_x);
+ ok(dpi_y == 96.0, "expected 96.0, got %f\n", dpi_y);
+
+ hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format);
+ ok(hr == S_OK, "GetPixelFormat error %#x\n", hr);
+ ok(IsEqualGUID(&format, &GUID_WICPixelFormat32bppPBGRA),
+ "got wrong format %s\n", wine_dbgstr_guid(&format));
+
+ hr = IWICImagingFactory_CreatePalette(factory, &palette);
+ ok(hr == S_OK, "CreatePalette error %#x\n", hr);
+ hr = IWICBitmapFrameDecode_CopyPalette(frame, palette);
+ ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE,
+ "expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %#x\n", hr);
+ IWICPalette_Release(palette);
+
+ rc.X = 0;
+ rc.Y = 0;
+ rc.Width = 2;
+ rc.Height = 2;
+ hr = IWICBitmapFrameDecode_CopyPixels(frame, &rc, 8, sizeof(data), data);
+ ok(hr == S_OK, "CopyPixels error %#x\n", hr);
+
+ for (i = 0; i < sizeof(data); i++)
+ ok(data[i] == expected_data[i], "%u: expected %02x, got %02x\n", i, expected_data[i], data[i]);
+
+ IWICBitmapFrameDecode_Release(frame);
+ IWICBitmapDecoder_Release(decoder);
+}
+
START_TEST(tiffformat)
{
HRESULT hr;
@@ -277,6 +379,7 @@ START_TEST(tiffformat)
test_tiff_palette();
test_QueryCapability();
+ test_tiff_8bpp_alpha();
IWICImagingFactory_Release(factory);
CoUninitialize();
diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c
index 7f987de..51e940f 100644
--- a/dlls/windowscodecs/tiffformat.c
+++ b/dlls/windowscodecs/tiffformat.c
@@ -236,7 +236,7 @@ typedef struct {
const WICPixelFormatGUID *format;
int bps;
int samples;
- int bpp;
+ int bpp, source_bpp;
int planar;
int indexed;
int reverse_bgr;
@@ -326,23 +326,63 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info)
decode_info->invert_grayscale = 1;
/* fall through */
case 1: /* BlackIsZero */
- if (samples != 1)
+ if (samples == 2)
+ {
+ ret = pTIFFGetField(tiff, TIFFTAG_EXTRASAMPLES, &extra_sample_count, &extra_samples);
+ if (!ret)
+ {
+ extra_sample_count = 1;
+ extra_sample = 0;
+ extra_samples = &extra_sample;
+ }
+ }
+ else if (samples != 1)
{
- FIXME("unhandled grayscale sample count %u\n", samples);
+ FIXME("unhandled %dbpp sample count %u\n", bps, samples);
return E_FAIL;
}
- decode_info->bpp = bps;
+ decode_info->bpp = bps * samples;
+ decode_info->source_bpp = decode_info->bpp;
switch (bps)
{
case 1:
+ if (samples != 1)
+ {
+ FIXME("unhandled 1bpp sample count %u\n", samples);
+ return E_FAIL;
+ }
decode_info->format = &GUID_WICPixelFormatBlackWhite;
break;
case 4:
+ if (samples != 1)
+ {
+ FIXME("unhandled 4bpp grayscale sample count %u\n", samples);
+ return E_FAIL;
+ }
decode_info->format = &GUID_WICPixelFormat4bppGray;
break;
case 8:
- decode_info->format = &GUID_WICPixelFormat8bppGray;
+ if (samples == 1)
+ decode_info->format = &GUID_WICPixelFormat8bppGray;
+ else
+ {
+ decode_info->bpp = 32;
+
+ switch(extra_samples[0])
+ {
+ case 1: /* Associated (pre-multiplied) alpha data */
+ decode_info->format = &GUID_WICPixelFormat32bppPBGRA;
+ break;
+ case 0: /* Unspecified data */
+ case 2: /* Unassociated alpha data */
+ decode_info->format = &GUID_WICPixelFormat32bppBGRA;
+ break;
+ default:
+ FIXME("unhandled extra sample type %u\n", extra_samples[0]);
+ return E_FAIL;
+ }
+ }
break;
default:
FIXME("unhandled greyscale bit count %u\n", bps);
@@ -943,6 +983,22 @@ static HRESULT TiffFrameDecode_ReadTile(TiffFrameDecode *This, UINT tile_x, UINT
hr = E_FAIL;
}
+ /* 8bpp grayscale with extra alpha */
+ if (hr == S_OK && This->decode_info.source_bpp == 16 && This->decode_info.samples == 2 && This->decode_info.bpp == 32)
+ {
+ BYTE *src;
+ DWORD *dst, count = This->decode_info.tile_width * This->decode_info.tile_height;
+
+ src = This->cached_tile + This->decode_info.tile_width * This->decode_info.tile_height * 2 - 2;
+ dst = (DWORD *)(This->cached_tile + This->decode_info.tile_size - 4);
+
+ while (count--)
+ {
+ *dst-- = src[0] | (src[0] << 8) | (src[0] << 16) | (src[1] << 24);
+ src -= 2;
+ }
+ }
+
if (hr == S_OK && This->decode_info.reverse_bgr)
{
if (This->decode_info.bps == 8)
--
2.3.3

View File

@ -1,38 +0,0 @@
From 905f0a28d10fa0e67b8c2580d65f9001bc15f92a Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sat, 21 Feb 2015 11:23:58 +0100
Subject: windowscodecs: Ignore unsupported alpha channel in
tiff_get_decode_info.
---
dlls/windowscodecs/tiffformat.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c
index 74a73bc..6302c28 100644
--- a/dlls/windowscodecs/tiffformat.c
+++ b/dlls/windowscodecs/tiffformat.c
@@ -326,7 +326,19 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info)
decode_info->invert_grayscale = 1;
/* fall through */
case 1: /* BlackIsZero */
- if (samples != 1)
+ if (samples == 2)
+ {
+ ret = pTIFFGetField(tiff, TIFFTAG_EXTRASAMPLES, &extra_sample_count, &extra_samples);
+ if (!ret)
+ {
+ extra_sample_count = 1;
+ extra_sample = 0;
+ extra_samples = &extra_sample;
+ }
+ else
+ FIXME("ignoring extra alpha %u/%u bps %u\n", extra_sample_count, extra_samples[0], bps);
+ }
+ else if (samples != 1)
{
FIXME("unhandled grayscale sample count %u\n", samples);
return E_FAIL;
--
2.3.0

View File

@ -1 +1 @@
Fixes: [38027] Ignore unsupported alpha channels in TIFF decoder
Fixes: [38027] Support for 8bpp grayscale TIFF images with 8bpp alpha channel