Vincent Povirk : windowscodecs: Always check TIFF sample count and planar configuration.

Alexandre Julliard julliard at winehq.org
Wed Aug 25 12:35:04 CDT 2010


Module: wine
Branch: master
Commit: 73d539e65703236dac2d57ca1addd038d08aec3f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=73d539e65703236dac2d57ca1addd038d08aec3f

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Sat May 29 10:58:05 2010 -0500

windowscodecs: Always check TIFF sample count and planar configuration.

This more closely matches the TIFF spec. These values are valid for all
photometric interpretations.

---

 dlls/windowscodecs/tiffformat.c |   48 +++++++++++++++++++++++++++-----------
 1 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c
index c92a2f2..58515c5 100644
--- a/dlls/windowscodecs/tiffformat.c
+++ b/dlls/windowscodecs/tiffformat.c
@@ -202,6 +202,7 @@ typedef struct {
     int bps;
     int samples;
     int bpp;
+    int planar;
     int indexed;
     int reverse_bgr;
     UINT width, height;
@@ -224,7 +225,7 @@ static const IWICBitmapFrameDecodeVtbl TiffFrameDecode_Vtbl;
 
 static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info)
 {
-    uint16 photometric, bps, samples=1, planar;
+    uint16 photometric, bps, samples, planar;
     int ret;
 
     decode_info->indexed = 0;
@@ -239,12 +240,35 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info)
 
     ret = pTIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE, &bps);
     if (!ret) bps = 1;
-
     decode_info->bps = bps;
 
+    ret = pTIFFGetField(tiff, TIFFTAG_SAMPLESPERPIXEL, &samples);
+    if (!ret) samples = 1;
+    decode_info->samples = samples;
+
+    if (samples == 1)
+        planar = 1;
+    else
+    {
+        ret = pTIFFGetField(tiff, TIFFTAG_PLANARCONFIG, &planar);
+        if (!ret) planar = 1;
+        if (planar != 1)
+        {
+            FIXME("unhandled planar configuration %u\n", planar);
+            return E_FAIL;
+        }
+    }
+    decode_info->planar = planar;
+
     switch(photometric)
     {
     case 1: /* BlackIsZero */
+        if (samples != 1)
+        {
+            FIXME("unhandled grayscale sample count %u\n", samples);
+            return E_FAIL;
+        }
+
         decode_info->bpp = bps;
         switch (bps)
         {
@@ -263,22 +287,14 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info)
         }
         break;
     case 2: /* RGB */
-        ret = pTIFFGetField(tiff, TIFFTAG_PLANARCONFIG, &planar);
-        if (!ret) planar = 1;
-        if (planar != 1)
-        {
-            FIXME("unhandled planar configuration %u\n", planar);
-            return E_FAIL;
-        }
-        ret = pTIFFGetField(tiff, TIFFTAG_SAMPLESPERPIXEL, &samples);
+        decode_info->bpp = bps * samples;
+
         if (samples != 3)
         {
             FIXME("unhandled RGB sample count %u\n", samples);
             return E_FAIL;
         }
 
-        decode_info->bpp = bps * samples;
-
         switch(bps)
         {
         case 8:
@@ -294,6 +310,12 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info)
         }
         break;
     case 3: /* RGB Palette */
+        if (samples != 1)
+        {
+            FIXME("unhandled indexed sample count %u\n", samples);
+            return E_FAIL;
+        }
+
         decode_info->indexed = 1;
         decode_info->bpp = bps;
         switch (bps)
@@ -319,8 +341,6 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info)
         return E_FAIL;
     }
 
-    decode_info->samples = samples;
-
     ret = pTIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &decode_info->width);
     if (!ret)
     {




More information about the wine-cvs mailing list