Vincent Povirk : windowscodecs: Implement TiffDecoder_GetResolution.

Alexandre Julliard julliard at winehq.org
Wed Apr 6 11:36:35 CDT 2011


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Tue Apr  5 16:42:44 2011 -0500

windowscodecs: Implement TiffDecoder_GetResolution.

---

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

diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c
index b1dd152..1e82285 100644
--- a/dlls/windowscodecs/tiffformat.c
+++ b/dlls/windowscodecs/tiffformat.c
@@ -219,6 +219,8 @@ typedef struct {
     UINT tile_size;
     int tiled;
     UINT tiles_across;
+    UINT resolution_unit;
+    float xres, yres;
 } tiff_decode_info;
 
 typedef struct {
@@ -458,6 +460,25 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info)
         return E_FAIL;
     }
 
+    decode_info->resolution_unit = 0;
+    pTIFFGetField(tiff, TIFFTAG_RESOLUTIONUNIT, &decode_info->resolution_unit);
+    if (decode_info->resolution_unit != 0)
+    {
+        ret = pTIFFGetField(tiff, TIFFTAG_XRESOLUTION, &decode_info->xres);
+        if (!ret)
+        {
+            WARN("missing X resolution\n");
+            decode_info->resolution_unit = 0;
+        }
+
+        ret = pTIFFGetField(tiff, TIFFTAG_YRESOLUTION, &decode_info->yres);
+        if (!ret)
+        {
+            WARN("missing Y resolution\n");
+            decode_info->resolution_unit = 0;
+        }
+    }
+
     return S_OK;
 }
 
@@ -769,8 +790,33 @@ static HRESULT WINAPI TiffFrameDecode_GetPixelFormat(IWICBitmapFrameDecode *ifac
 static HRESULT WINAPI TiffFrameDecode_GetResolution(IWICBitmapFrameDecode *iface,
     double *pDpiX, double *pDpiY)
 {
-    FIXME("(%p,%p,%p)\n", iface, pDpiX, pDpiY);
-    return E_NOTIMPL;
+    TiffFrameDecode *This = impl_from_IWICBitmapFrameDecode(iface);
+
+    switch (This->decode_info.resolution_unit)
+    {
+    default:
+        FIXME("unknown resolution unit %i\n", This->decode_info.resolution_unit);
+        /* fall through */
+    case 0: /* Not set */
+        *pDpiX = *pDpiY = 96.0;
+        break;
+    case 1: /* Relative measurements */
+        *pDpiX = 96.0;
+        *pDpiY = 96.0 * This->decode_info.yres / This->decode_info.xres;
+        break;
+    case 2: /* Inch */
+        *pDpiX = This->decode_info.xres;
+        *pDpiY = This->decode_info.yres;
+        break;
+    case 3: /* Centimeter */
+        *pDpiX = This->decode_info.xres / 2.54;
+        *pDpiY = This->decode_info.yres / 2.54;
+        break;
+    }
+
+    TRACE("(%p) <-- %f,%f unit=%i\n", iface, *pDpiX, *pDpiY, This->decode_info.resolution_unit);
+
+    return S_OK;
 }
 
 static HRESULT WINAPI TiffFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface,




More information about the wine-cvs mailing list