Vincent Povirk : windowscodecs: Add support for reading tiled TIFF images.

Alexandre Julliard julliard at winehq.org
Mon Mar 28 14:21:59 CDT 2011


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Fri Mar 25 15:59:41 2011 -0500

windowscodecs: Add support for reading tiled TIFF images.

---

 dlls/windowscodecs/tiffformat.c |   39 +++++++++++++++++++++++++++++++++++----
 1 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c
index 976870a..b1dd152 100644
--- a/dlls/windowscodecs/tiffformat.c
+++ b/dlls/windowscodecs/tiffformat.c
@@ -62,6 +62,7 @@ MAKE_FUNCPTR(TIFFGetField);
 MAKE_FUNCPTR(TIFFIsByteSwapped);
 MAKE_FUNCPTR(TIFFReadDirectory);
 MAKE_FUNCPTR(TIFFReadEncodedStrip);
+MAKE_FUNCPTR(TIFFReadEncodedTile);
 MAKE_FUNCPTR(TIFFSetDirectory);
 #undef MAKE_FUNCPTR
 
@@ -89,6 +90,7 @@ static void *load_libtiff(void)
         LOAD_FUNCPTR(TIFFIsByteSwapped);
         LOAD_FUNCPTR(TIFFReadDirectory);
         LOAD_FUNCPTR(TIFFReadEncodedStrip);
+        LOAD_FUNCPTR(TIFFReadEncodedTile);
         LOAD_FUNCPTR(TIFFSetDirectory);
 #undef LOAD_FUNCPTR
 
@@ -215,6 +217,8 @@ typedef struct {
     UINT tile_width, tile_height;
     UINT tile_stride;
     UINT tile_size;
+    int tiled;
+    UINT tiles_across;
 } tiff_decode_info;
 
 typedef struct {
@@ -248,6 +252,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;
+    decode_info->tiled = 0;
 
     ret = pTIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric);
     if (!ret)
@@ -418,8 +423,28 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info)
         return E_FAIL;
     }
 
-    ret = pTIFFGetField(tiff, TIFFTAG_ROWSPERSTRIP, &decode_info->tile_height);
-    if (ret)
+    if ((ret = pTIFFGetField(tiff, TIFFTAG_TILEWIDTH, &decode_info->tile_width)))
+    {
+        decode_info->tiled = 1;
+
+        if (!ret)
+        {
+            WARN("missing tile width\n");
+            return E_FAIL;
+        }
+
+        ret = pTIFFGetField(tiff, TIFFTAG_TILELENGTH, &decode_info->tile_height);
+        if (!ret)
+        {
+            WARN("missing tile height\n");
+            return E_FAIL;
+        }
+
+        decode_info->tile_stride = ((decode_info->bpp * decode_info->tile_width + 7)/8);
+        decode_info->tile_size = decode_info->tile_height * decode_info->tile_stride;
+        decode_info->tiles_across = (decode_info->width + decode_info->tile_width - 1) / decode_info->tile_width;
+    }
+    else if ((ret = pTIFFGetField(tiff, TIFFTAG_ROWSPERSTRIP, &decode_info->tile_height)))
     {
         if (decode_info->tile_height > decode_info->height)
             decode_info->tile_height = decode_info->height;
@@ -429,7 +454,6 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info)
     }
     else
     {
-        /* Probably a tiled image */
         FIXME("missing RowsPerStrip value\n");
         return E_FAIL;
     }
@@ -797,7 +821,14 @@ static HRESULT TiffFrameDecode_ReadTile(TiffFrameDecode *This, UINT tile_x, UINT
 
     if (hr == S_OK)
     {
-        ret = pTIFFReadEncodedStrip(This->parent->tiff, tile_y, This->cached_tile, This->decode_info.tile_size);
+        if (This->decode_info.tiled)
+        {
+            ret = pTIFFReadEncodedTile(This->parent->tiff, tile_x + tile_y * This->decode_info.tiles_across, This->cached_tile, This->decode_info.tile_size);
+        }
+        else
+        {
+            ret = pTIFFReadEncodedStrip(This->parent->tiff, tile_y, This->cached_tile, This->decode_info.tile_size);
+        }
 
         if (ret == -1)
             hr = E_FAIL;




More information about the wine-cvs mailing list