[PATCH] windowscodecs: Implemented GifFrameDecode_GetResolution
Joel Holdsworth
joel at airwebreathe.org.uk
Wed Oct 6 17:44:34 CDT 2010
---
dlls/windowscodecs/gifformat.c | 10 ++++++++--
dlls/windowscodecs/tests/bmpformat.c | 13 +++++++++++--
dlls/windowscodecs/ungif.c | 1 +
dlls/windowscodecs/ungif.h | 3 ++-
4 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/dlls/windowscodecs/gifformat.c b/dlls/windowscodecs/gifformat.c
index 3443b2c..d6c701e 100644
--- a/dlls/windowscodecs/gifformat.c
+++ b/dlls/windowscodecs/gifformat.c
@@ -123,8 +123,14 @@ static HRESULT WINAPI GifFrameDecode_GetPixelFormat(IWICBitmapFrameDecode *iface
static HRESULT WINAPI GifFrameDecode_GetResolution(IWICBitmapFrameDecode *iface,
double *pDpiX, double *pDpiY)
{
- FIXME("(%p,%p,%p): stub\n", iface, pDpiX, pDpiY);
- return E_NOTIMPL;
+ GifFrameDecode *This = (GifFrameDecode*)iface;
+ const GifWord aspect_word = This->parent->gif->SAspectRatio;
+ const double aspect = (aspect_word > 0) ? ((aspect_word + 15.0) / 64.0) : 1.0;
+
+ *pDpiX = 96.0 / aspect;
+ *pDpiY = 96.0;
+
+ return S_OK;
}
static HRESULT WINAPI GifFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface,
diff --git a/dlls/windowscodecs/tests/bmpformat.c b/dlls/windowscodecs/tests/bmpformat.c
index f817df5..0fcdc06 100644
--- a/dlls/windowscodecs/tests/bmpformat.c
+++ b/dlls/windowscodecs/tests/bmpformat.c
@@ -1042,7 +1042,7 @@ static void test_createfromstream(void)
/* 1x1 pixel gif, missing trailer */
static unsigned char gifimage_notrailer[] = {
-0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x00,0xff,0xff,0xff,
+0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x71,0xff,0xff,0xff,
0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44,
0x01,0x00
};
@@ -1054,6 +1054,7 @@ static void test_gif_notrailer(void)
HRESULT hr;
IWICStream *gifstream;
IWICBitmapFrameDecode *framedecode;
+ double dpiX = 0.0, dpiY = 0.0;
UINT framecount;
hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
@@ -1086,7 +1087,15 @@ static void test_gif_notrailer(void)
{
hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
ok(hr == S_OK, "GetFrame failed, hr=%x\n", hr);
- if (SUCCEEDED(hr)) IWICBitmapFrameDecode_Release(framedecode);
+ if (SUCCEEDED(hr))
+ {
+ hr = IWICBitmapFrameDecode_GetResolution(framedecode, &dpiX, &dpiY);
+ ok(SUCCEEDED(hr), "GetResolution failed, hr=%x\n", hr);
+ ok(dpiX == 48.0, "expected dpiX=48.0, got %f\n", dpiX);
+ ok(dpiY == 96.0, "expected dpiY=96.0, got %f\n", dpiY);
+
+ IWICBitmapFrameDecode_Release(framedecode);
+ }
}
if (SUCCEEDED(hr))
diff --git a/dlls/windowscodecs/ungif.c b/dlls/windowscodecs/ungif.c
index cfc7613..87a9331 100644
--- a/dlls/windowscodecs/ungif.c
+++ b/dlls/windowscodecs/ungif.c
@@ -285,6 +285,7 @@ DGifGetScreenDesc(GifFileType * GifFile) {
GifFile->SColorResolution = (((Buf[0] & 0x70) + 1) >> 4) + 1;
BitsPerPixel = (Buf[0] & 0x07) + 1;
GifFile->SBackGroundColor = Buf[1];
+ GifFile->SAspectRatio = Buf[2];
if (Buf[0] & 0x80) { /* Do we have global color map? */
GifFile->SColorMap = MakeMapObject(1 << BitsPerPixel, NULL);
diff --git a/dlls/windowscodecs/ungif.h b/dlls/windowscodecs/ungif.h
index e71dad8..5e39c56 100644
--- a/dlls/windowscodecs/ungif.h
+++ b/dlls/windowscodecs/ungif.h
@@ -100,7 +100,8 @@ typedef struct GifImageDesc {
typedef struct GifFileType {
GifWord SWidth, SHeight, /* Screen dimensions. */
SColorResolution, /* How many colors can we generate? */
- SBackGroundColor; /* I hope you understand this one... */
+ SBackGroundColor, /* I hope you understand this one... */
+ SAspectRatio; /* Pixel aspect ratio, in 1/64 units, starting at 1:4. */
ColorMapObject *SColorMap; /* NULL if not exists. */
int ImageCount; /* Number of current image */
GifImageDesc Image; /* Block describing current image */
--
1.7.0.4
--=-3/9MeqKJ63JV0w17fvJd--
More information about the wine-patches
mailing list