[SHELL32] CDrivesFolder: Implement the eject and disconnect menu items. CORE-13841
[reactos.git] / dll / win32 / windowscodecs / bmpdecode.c
index 60fc147..395f71f 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#define WIN32_NO_STATUS
-#define _INC_WINDOWS
-#define COM_NO_WINDOWS_H
-
-#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;
@@ -276,7 +256,7 @@ static HRESULT WINAPI BmpFrameDecode_CopyPalette(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);
@@ -1189,17 +1169,15 @@ static HRESULT BmpDecoder_Create(int packed, int icoframe, BmpDecoder **ppDecode
     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;
 
@@ -1209,14 +1187,14 @@ static HRESULT BmpDecoder_Construct(int packed, int icoframe, IUnknown *pUnkOute
     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)