Commit f9b67b6c authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

windowscodecs: Add a stub IWICBitmap implementation.

parent c2001c2b
......@@ -6,6 +6,7 @@ EXTRADEFS = -DENTRY_PREFIX=WIC_ -DPROXY_DELEGATION -DWINE_REGISTER_DLL -DWIDL_C_
EXTRALIBS = @APPLICATIONSERVICESLIB@
C_SRCS = \
bitmap.c \
bmpdecode.c \
bmpencode.c \
clsfactory.c \
......
/*
* Copyright 2012 Vincent Povirk for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdarg.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "wincodec.h"
#include "wincodecs_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
typedef struct BitmapImpl {
IWICBitmap IWICBitmap_iface;
LONG ref;
} BitmapImpl;
static inline BitmapImpl *impl_from_IWICBitmap(IWICBitmap *iface)
{
return CONTAINING_RECORD(iface, BitmapImpl, IWICBitmap_iface);
}
static HRESULT WINAPI BitmapImpl_QueryInterface(IWICBitmap *iface, REFIID iid,
void **ppv)
{
BitmapImpl *This = impl_from_IWICBitmap(iface);
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
if (!ppv) return E_INVALIDARG;
if (IsEqualIID(&IID_IUnknown, iid) ||
IsEqualIID(&IID_IWICBitmapSource, iid) ||
IsEqualIID(&IID_IWICBitmap, iid))
{
*ppv = &This->IWICBitmap_iface;
}
else
{
*ppv = NULL;
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI BitmapImpl_AddRef(IWICBitmap *iface)
{
BitmapImpl *This = impl_from_IWICBitmap(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) refcount=%u\n", iface, ref);
return ref;
}
static ULONG WINAPI BitmapImpl_Release(IWICBitmap *iface)
{
BitmapImpl *This = impl_from_IWICBitmap(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) refcount=%u\n", iface, ref);
if (ref == 0)
{
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
static HRESULT WINAPI BitmapImpl_GetSize(IWICBitmap *iface,
UINT *puiWidth, UINT *puiHeight)
{
FIXME("(%p,%p,%p)\n", iface, puiWidth, puiHeight);
return E_NOTIMPL;
}
static HRESULT WINAPI BitmapImpl_GetPixelFormat(IWICBitmap *iface,
WICPixelFormatGUID *pPixelFormat)
{
FIXME("(%p,%p)\n", iface, pPixelFormat);
return E_NOTIMPL;
}
static HRESULT WINAPI BitmapImpl_GetResolution(IWICBitmap *iface,
double *pDpiX, double *pDpiY)
{
FIXME("(%p,%p,%p)\n", iface, pDpiX, pDpiY);
return E_NOTIMPL;
}
static HRESULT WINAPI BitmapImpl_CopyPalette(IWICBitmap *iface,
IWICPalette *pIPalette)
{
FIXME("(%p,%p)\n", iface, pIPalette);
return E_NOTIMPL;
}
static HRESULT WINAPI BitmapImpl_CopyPixels(IWICBitmap *iface,
const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
{
FIXME("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
return E_NOTIMPL;
}
static HRESULT WINAPI BitmapImpl_Lock(IWICBitmap *iface, const WICRect *prcLock,
DWORD flags, IWICBitmapLock **ppILock)
{
FIXME("(%p,%p,%x,%p)\n", iface, prcLock, flags, ppILock);
return E_NOTIMPL;
}
static HRESULT WINAPI BitmapImpl_SetPalette(IWICBitmap *iface, IWICPalette *pIPalette)
{
FIXME("(%p,%p)\n", iface, pIPalette);
return E_NOTIMPL;
}
static HRESULT WINAPI BitmapImpl_SetResolution(IWICBitmap *iface,
double dpiX, double dpiY)
{
FIXME("(%p,%f,%f)\n", iface, dpiX, dpiY);
return E_NOTIMPL;
}
static const IWICBitmapVtbl BitmapImpl_Vtbl = {
BitmapImpl_QueryInterface,
BitmapImpl_AddRef,
BitmapImpl_Release,
BitmapImpl_GetSize,
BitmapImpl_GetPixelFormat,
BitmapImpl_GetResolution,
BitmapImpl_CopyPalette,
BitmapImpl_CopyPixels,
BitmapImpl_Lock,
BitmapImpl_SetPalette,
BitmapImpl_SetResolution
};
HRESULT BitmapImpl_Create(UINT uiWidth, UINT uiHeight,
REFWICPixelFormatGUID pixelFormat, WICBitmapCreateCacheOption option,
IWICBitmap **ppIBitmap)
{
BitmapImpl *This;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapImpl));
if (!This) return E_OUTOFMEMORY;
This->IWICBitmap_iface.lpVtbl = &BitmapImpl_Vtbl;
This->ref = 1;
*ppIBitmap = &This->IWICBitmap_iface;
return S_OK;
}
......@@ -457,9 +457,9 @@ static HRESULT WINAPI ComponentFactory_CreateBitmap(IWICComponentFactory *iface,
UINT uiWidth, UINT uiHeight, REFWICPixelFormatGUID pixelFormat,
WICBitmapCreateCacheOption option, IWICBitmap **ppIBitmap)
{
FIXME("(%p,%u,%u,%s,%u,%p): stub\n", iface, uiWidth, uiHeight,
TRACE("(%p,%u,%u,%s,%u,%p)\n", iface, uiWidth, uiHeight,
debugstr_guid(pixelFormat), option, ppIBitmap);
return E_NOTIMPL;
return BitmapImpl_Create(uiWidth, uiHeight, pixelFormat, option, ppIBitmap);
}
static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFactory *iface,
......
......@@ -52,7 +52,7 @@ static void test_createbitmap(void)
hr = IWICImagingFactory_CreateBitmap(factory, 3, 3, &GUID_WICPixelFormat24bppBGR,
WICBitmapCacheOnLoad, &bitmap);
todo_wine ok(hr == S_OK, "IWICImagingFactory_CreateBitmap failed hr=%x\n", hr);
ok(hr == S_OK, "IWICImagingFactory_CreateBitmap failed hr=%x\n", hr);
if (FAILED(hr))
return;
......@@ -62,34 +62,35 @@ static void test_createbitmap(void)
/* Palette is unavailable until explicitly set */
hr = IWICBitmap_CopyPalette(bitmap, palette);
ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "IWICBitmap_CopyPalette failed hr=%x\n", hr);
todo_wine ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "IWICBitmap_CopyPalette failed hr=%x\n", hr);
hr = IWICPalette_InitializePredefined(palette, WICBitmapPaletteTypeFixedGray256, FALSE);
ok(hr == S_OK, "IWICPalette_InitializePredefined failed hr=%x\n", hr);
hr = IWICBitmap_SetPalette(bitmap, palette);
ok(hr == S_OK, "IWICBitmap_SetPalette failed hr=%x\n", hr);
todo_wine ok(hr == S_OK, "IWICBitmap_SetPalette failed hr=%x\n", hr);
hr = IWICPalette_InitializePredefined(palette, WICBitmapPaletteTypeFixedGray4, FALSE);
ok(hr == S_OK, "IWICPalette_InitializePredefined failed hr=%x\n", hr);
hr = IWICBitmap_CopyPalette(bitmap, palette);
ok(hr == S_OK, "IWICBitmap_CopyPalette failed hr=%x\n", hr);
todo_wine ok(hr == S_OK, "IWICBitmap_CopyPalette failed hr=%x\n", hr);
hr = IWICPalette_GetType(palette, &palettetype);
ok(hr == S_OK, "IWICPalette_GetType failed hr=%x\n", hr);
ok(palettetype == WICBitmapPaletteTypeFixedGray256,
todo_wine ok(palettetype == WICBitmapPaletteTypeFixedGray256,
"expected WICBitmapPaletteTypeFixedGray256, got %x\n", palettetype);
IWICPalette_Release(palette);
/* pixel data is initially zeroed */
hr = IWICBitmap_CopyPixels(bitmap, NULL, 9, 27, returned_data);
ok(hr == S_OK, "IWICBitmap_CopyPixels failed hr=%x\n", hr);
todo_wine ok(hr == S_OK, "IWICBitmap_CopyPixels failed hr=%x\n", hr);
for (i=0; i<27; i++)
ok(returned_data[i] == 0, "returned_data[%i] == %i\n", i, returned_data[i]);
todo_wine {
/* Invalid lock rects */
rc.X = rc.Y = 0;
rc.Width = 4;
......@@ -257,6 +258,7 @@ static void test_createbitmap(void)
ok(hr == S_OK, "IWICBitmap_GetSize failed hr=%x\n", hr);
ok(width == 3, "got %d, expected 3\n", width);
ok(height == 3, "got %d, expected 3\n", height);
}
IWICBitmap_Release(bitmap);
}
......
......@@ -44,6 +44,9 @@ extern HRESULT IcnsEncoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void*
extern HRESULT TgaDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) DECLSPEC_HIDDEN;
extern HRESULT BitmapImpl_Create(UINT uiWidth, UINT uiHeight,
REFWICPixelFormatGUID pixelFormat, WICBitmapCreateCacheOption option,
IWICBitmap **ppIBitmap) DECLSPEC_HIDDEN;
extern HRESULT BitmapScaler_Create(IWICBitmapScaler **scaler) DECLSPEC_HIDDEN;
extern HRESULT FlipRotator_Create(IWICBitmapFlipRotator **fliprotator) DECLSPEC_HIDDEN;
extern HRESULT PaletteImpl_Create(IWICPalette **palette) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment