Vincent Povirk : windowscodecs: Handle WhiteIsZero TIFF images.

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


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Sat May 29 11:27:31 2010 -0500

windowscodecs: Handle WhiteIsZero TIFF images.

---

 dlls/windowscodecs/tiffformat.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c
index 58515c5..fe1fb00 100644
--- a/dlls/windowscodecs/tiffformat.c
+++ b/dlls/windowscodecs/tiffformat.c
@@ -205,6 +205,7 @@ typedef struct {
     int planar;
     int indexed;
     int reverse_bgr;
+    int invert_grayscale;
     UINT width, height;
     UINT tile_width, tile_height;
     UINT tile_stride;
@@ -230,6 +231,7 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info)
 
     decode_info->indexed = 0;
     decode_info->reverse_bgr = 0;
+    decode_info->invert_grayscale = 0;
 
     ret = pTIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric);
     if (!ret)
@@ -262,6 +264,8 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info)
 
     switch(photometric)
     {
+    case 0: /* WhiteIsZero */
+        decode_info->invert_grayscale = 1;
     case 1: /* BlackIsZero */
         if (samples != 1)
         {
@@ -331,7 +335,6 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info)
             return E_FAIL;
         }
         break;
-    case 0: /* WhiteIsZero */
     case 4: /* Transparency mask */
     case 5: /* CMYK */
     case 6: /* YCbCr */
@@ -759,6 +762,22 @@ static HRESULT TiffFrameDecode_ReadTile(TiffFrameDecode *This, UINT tile_x, UINT
         }
     }
 
+    if (hr == S_OK && This->decode_info.invert_grayscale)
+    {
+        BYTE *byte, *end;
+
+        if (This->decode_info.samples != 1)
+        {
+            ERR("cannot invert grayscale image with %u samples\n", This->decode_info.samples);
+            return E_FAIL;
+        }
+
+        end = This->cached_tile+This->decode_info.tile_size;
+
+        for (byte = This->cached_tile; byte != end; byte++)
+            *byte = ~(*byte);
+    }
+
     if (hr == S_OK)
     {
         This->cached_tile_x = tile_x;




More information about the wine-cvs mailing list