* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-
-#include <assert.h>
-#include <stdarg.h>
-
-#define COBJMACROS
-
-#include "windef.h"
-#include "winbase.h"
-#include "winreg.h"
-#include "wingdi.h"
-#include "objbase.h"
-#include "wincodec.h"
-
#include "wincodecs_private.h"
-#include "wine/debug.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
+#include <assert.h>
typedef struct {
DWORD bc2Size;
static HRESULT BmpHeader_GetResolution(BITMAPV5HEADER *bih, double *pDpiX, double *pDpiY)
{
+ LONG resx = 0, resy = 0;
+
switch (bih->bV5Size)
{
+ default:
case sizeof(BITMAPCOREHEADER):
- *pDpiX = 96.0;
- *pDpiY = 96.0;
- return S_OK;
+ break;
+
case sizeof(BITMAPCOREHEADER2):
case sizeof(BITMAPINFOHEADER):
case sizeof(BITMAPV4HEADER):
case sizeof(BITMAPV5HEADER):
- *pDpiX = bih->bV5XPelsPerMeter * 0.0254;
- *pDpiY = bih->bV5YPelsPerMeter * 0.0254;
- return S_OK;
- default:
- return E_FAIL;
+ resx = bih->bV5XPelsPerMeter;
+ resy = bih->bV5YPelsPerMeter;
+ break;
+ }
+
+ if (!resx || !resy)
+ {
+ *pDpiX = 96.0;
+ *pDpiY = 96.0;
}
+ else
+ {
+ *pDpiX = resx * 0.0254;
+ *pDpiY = resy * 0.0254;
+ }
+
+ return S_OK;
}
static HRESULT WINAPI BmpFrameDecode_GetResolution(IWICBitmapFrameDecode *iface,
if (This->bih.bV5ClrUsed == 0)
count = 1 << This->bih.bV5BitCount;
else
- count = This->bih.bV5ClrUsed;
+ count = min(This->bih.bV5ClrUsed, 1 << This->bih.bV5BitCount);
tablesize = sizeof(WICColor) * count;
wiccolors = HeapAlloc(GetProcessHeap(), 0, tablesize);
return S_OK;
}
-static HRESULT BmpDecoder_Construct(int packed, int icoframe, IUnknown *pUnkOuter, REFIID iid, void** ppv)
+static HRESULT BmpDecoder_Construct(int packed, int icoframe, REFIID iid, void** ppv)
{
BmpDecoder *This;
HRESULT ret;
- TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv);
+ TRACE("(%s,%p)\n", debugstr_guid(iid), ppv);
*ppv = NULL;
- if (pUnkOuter) return CLASS_E_NOAGGREGATION;
-
ret = BmpDecoder_Create(packed, icoframe, &This);
if (FAILED(ret)) return ret;
return ret;
}
-HRESULT BmpDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
+HRESULT BmpDecoder_CreateInstance(REFIID iid, void** ppv)
{
- return BmpDecoder_Construct(FALSE, FALSE, pUnkOuter, iid, ppv);
+ return BmpDecoder_Construct(FALSE, FALSE, iid, ppv);
}
-HRESULT DibDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
+HRESULT DibDecoder_CreateInstance(REFIID iid, void** ppv)
{
- return BmpDecoder_Construct(TRUE, FALSE, pUnkOuter, iid, ppv);
+ return BmpDecoder_Construct(TRUE, FALSE, iid, ppv);
}
HRESULT IcoDibDecoder_CreateInstance(BmpDecoder **ppDecoder)