2012-08-14 20:39:15 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Vincent Povirk for CodeWeavers
|
2019-05-15 05:36:20 +02:00
|
|
|
* Copyright 2016 Dmitry Timoshkov
|
2012-08-14 20:39:15 +02:00
|
|
|
*
|
|
|
|
* 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 "wincodecs_private.h"
|
|
|
|
|
2019-05-15 05:36:20 +02:00
|
|
|
#include "wine/asm.h"
|
2012-08-14 20:39:15 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
|
|
|
|
|
2013-10-14 05:07:06 +02:00
|
|
|
/* WARNING: .NET Media Integration Layer (MIL) directly dereferences
|
|
|
|
* BitmapImpl members and depends on its exact layout.
|
|
|
|
*/
|
2012-08-14 20:39:15 +02:00
|
|
|
typedef struct BitmapImpl {
|
2013-10-14 05:07:06 +02:00
|
|
|
IMILUnknown1 IMILUnknown1_iface;
|
2012-08-14 20:39:15 +02:00
|
|
|
LONG ref;
|
2019-05-15 05:36:20 +02:00
|
|
|
IMILBitmap IMILBitmap_iface;
|
2013-10-14 05:07:06 +02:00
|
|
|
IWICBitmap IWICBitmap_iface;
|
|
|
|
IMILUnknown2 IMILUnknown2_iface;
|
2012-08-14 21:01:11 +02:00
|
|
|
IWICPalette *palette;
|
|
|
|
int palette_set;
|
2012-08-14 21:50:07 +02:00
|
|
|
LONG lock; /* 0 if not locked, -1 if locked for writing, count if locked for reading */
|
2012-08-14 22:24:58 +02:00
|
|
|
BYTE *data;
|
2018-03-21 10:28:27 +01:00
|
|
|
void *view; /* used if data is a section created by an application */
|
|
|
|
UINT offset; /* offset into view */
|
2012-08-14 22:24:58 +02:00
|
|
|
UINT width, height;
|
|
|
|
UINT stride;
|
|
|
|
UINT bpp;
|
2012-08-14 22:39:58 +02:00
|
|
|
WICPixelFormatGUID pixelformat;
|
2012-08-14 22:54:10 +02:00
|
|
|
double dpix, dpiy;
|
|
|
|
CRITICAL_SECTION cs;
|
2012-08-14 20:39:15 +02:00
|
|
|
} BitmapImpl;
|
|
|
|
|
2012-08-14 21:50:07 +02:00
|
|
|
typedef struct BitmapLockImpl {
|
|
|
|
IWICBitmapLock IWICBitmapLock_iface;
|
|
|
|
LONG ref;
|
|
|
|
BitmapImpl *parent;
|
2012-08-14 22:24:58 +02:00
|
|
|
UINT width, height;
|
|
|
|
BYTE *data;
|
2012-08-14 21:50:07 +02:00
|
|
|
} BitmapLockImpl;
|
|
|
|
|
2012-08-14 20:39:15 +02:00
|
|
|
static inline BitmapImpl *impl_from_IWICBitmap(IWICBitmap *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BitmapImpl, IWICBitmap_iface);
|
|
|
|
}
|
|
|
|
|
2019-05-15 05:36:20 +02:00
|
|
|
static inline BitmapImpl *impl_from_IMILBitmap(IMILBitmap *iface)
|
2013-10-14 05:07:06 +02:00
|
|
|
{
|
2019-05-15 05:36:20 +02:00
|
|
|
return CONTAINING_RECORD(iface, BitmapImpl, IMILBitmap_iface);
|
2013-10-14 05:07:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline BitmapImpl *impl_from_IMILUnknown1(IMILUnknown1 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BitmapImpl, IMILUnknown1_iface);
|
|
|
|
}
|
|
|
|
|
2012-08-14 21:50:07 +02:00
|
|
|
static inline BitmapLockImpl *impl_from_IWICBitmapLock(IWICBitmapLock *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BitmapLockImpl, IWICBitmapLock_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL BitmapImpl_AcquireLock(BitmapImpl *This, int write)
|
|
|
|
{
|
|
|
|
if (write)
|
|
|
|
{
|
|
|
|
return 0 == InterlockedCompareExchange(&This->lock, -1, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
LONG prev_val = This->lock;
|
|
|
|
if (prev_val == -1)
|
|
|
|
return FALSE;
|
|
|
|
if (prev_val == InterlockedCompareExchange(&This->lock, prev_val+1, prev_val))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void BitmapImpl_ReleaseLock(BitmapImpl *This)
|
|
|
|
{
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
LONG prev_val = This->lock, new_val;
|
|
|
|
if (prev_val == -1)
|
|
|
|
new_val = 0;
|
|
|
|
else
|
|
|
|
new_val = prev_val - 1;
|
|
|
|
if (prev_val == InterlockedCompareExchange(&This->lock, new_val, prev_val))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI BitmapLockImpl_QueryInterface(IWICBitmapLock *iface, REFIID iid,
|
|
|
|
void **ppv)
|
|
|
|
{
|
|
|
|
BitmapLockImpl *This = impl_from_IWICBitmapLock(iface);
|
|
|
|
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
|
|
|
|
|
|
|
|
if (!ppv) return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (IsEqualIID(&IID_IUnknown, iid) ||
|
|
|
|
IsEqualIID(&IID_IWICBitmapLock, iid))
|
|
|
|
{
|
|
|
|
*ppv = &This->IWICBitmapLock_iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-15 05:36:20 +02:00
|
|
|
FIXME("unknown interface %s\n", debugstr_guid(iid));
|
2012-08-14 21:50:07 +02:00
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BitmapLockImpl_AddRef(IWICBitmapLock *iface)
|
|
|
|
{
|
|
|
|
BitmapLockImpl *This = impl_from_IWICBitmapLock(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) refcount=%u\n", iface, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BitmapLockImpl_Release(IWICBitmapLock *iface)
|
|
|
|
{
|
|
|
|
BitmapLockImpl *This = impl_from_IWICBitmapLock(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) refcount=%u\n", iface, ref);
|
|
|
|
|
|
|
|
if (ref == 0)
|
|
|
|
{
|
|
|
|
BitmapImpl_ReleaseLock(This->parent);
|
|
|
|
IWICBitmap_Release(&This->parent->IWICBitmap_iface);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BitmapLockImpl_GetSize(IWICBitmapLock *iface,
|
|
|
|
UINT *puiWidth, UINT *puiHeight)
|
|
|
|
{
|
2012-08-14 22:24:58 +02:00
|
|
|
BitmapLockImpl *This = impl_from_IWICBitmapLock(iface);
|
|
|
|
TRACE("(%p,%p,%p)\n", iface, puiWidth, puiHeight);
|
2012-08-14 21:50:07 +02:00
|
|
|
|
2012-08-14 22:24:58 +02:00
|
|
|
if (!puiWidth || !puiHeight)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*puiWidth = This->width;
|
|
|
|
*puiHeight = This->height;
|
|
|
|
|
|
|
|
return S_OK;
|
2012-08-14 21:50:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BitmapLockImpl_GetStride(IWICBitmapLock *iface,
|
|
|
|
UINT *pcbStride)
|
|
|
|
{
|
2012-08-14 22:24:58 +02:00
|
|
|
BitmapLockImpl *This = impl_from_IWICBitmapLock(iface);
|
|
|
|
TRACE("(%p,%p)\n", iface, pcbStride);
|
2012-08-14 21:50:07 +02:00
|
|
|
|
2012-08-14 22:24:58 +02:00
|
|
|
if (!pcbStride)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*pcbStride = This->parent->stride;
|
|
|
|
|
|
|
|
return S_OK;
|
2012-08-14 21:50:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BitmapLockImpl_GetDataPointer(IWICBitmapLock *iface,
|
|
|
|
UINT *pcbBufferSize, BYTE **ppbData)
|
|
|
|
{
|
2012-08-14 22:24:58 +02:00
|
|
|
BitmapLockImpl *This = impl_from_IWICBitmapLock(iface);
|
|
|
|
TRACE("(%p,%p,%p)\n", iface, pcbBufferSize, ppbData);
|
2012-08-14 21:50:07 +02:00
|
|
|
|
2012-08-14 22:24:58 +02:00
|
|
|
if (!pcbBufferSize || !ppbData)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*pcbBufferSize = This->parent->stride * (This->height - 1) +
|
|
|
|
((This->parent->bpp * This->width) + 7)/8;
|
|
|
|
*ppbData = This->data;
|
|
|
|
|
|
|
|
return S_OK;
|
2012-08-14 21:50:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BitmapLockImpl_GetPixelFormat(IWICBitmapLock *iface,
|
|
|
|
WICPixelFormatGUID *pPixelFormat)
|
|
|
|
{
|
2012-08-14 22:39:58 +02:00
|
|
|
BitmapLockImpl *This = impl_from_IWICBitmapLock(iface);
|
|
|
|
TRACE("(%p,%p)\n", iface, pPixelFormat);
|
2012-08-14 21:50:07 +02:00
|
|
|
|
2012-08-14 22:39:58 +02:00
|
|
|
return IWICBitmap_GetPixelFormat(&This->parent->IWICBitmap_iface, pPixelFormat);
|
2012-08-14 21:50:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IWICBitmapLockVtbl BitmapLockImpl_Vtbl = {
|
|
|
|
BitmapLockImpl_QueryInterface,
|
|
|
|
BitmapLockImpl_AddRef,
|
|
|
|
BitmapLockImpl_Release,
|
|
|
|
BitmapLockImpl_GetSize,
|
|
|
|
BitmapLockImpl_GetStride,
|
|
|
|
BitmapLockImpl_GetDataPointer,
|
|
|
|
BitmapLockImpl_GetPixelFormat
|
|
|
|
};
|
|
|
|
|
2012-08-14 20:39:15 +02:00
|
|
|
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;
|
|
|
|
}
|
2019-05-15 05:36:20 +02:00
|
|
|
else if (IsEqualIID(&IID_IMILBitmap, iid) ||
|
|
|
|
IsEqualIID(&IID_IMILBitmapSource, iid))
|
2013-10-14 05:07:06 +02:00
|
|
|
{
|
2019-05-15 05:36:20 +02:00
|
|
|
*ppv = &This->IMILBitmap_iface;
|
2013-10-14 05:07:06 +02:00
|
|
|
}
|
2012-08-14 20:39:15 +02:00
|
|
|
else
|
|
|
|
{
|
2019-05-15 05:36:20 +02:00
|
|
|
FIXME("unknown interface %s\n", debugstr_guid(iid));
|
2012-08-14 20:39:15 +02:00
|
|
|
*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)
|
|
|
|
{
|
2012-08-14 21:01:11 +02:00
|
|
|
if (This->palette) IWICPalette_Release(This->palette);
|
2012-08-14 22:54:10 +02:00
|
|
|
This->cs.DebugInfo->Spare[0] = 0;
|
|
|
|
DeleteCriticalSection(&This->cs);
|
2018-03-21 10:28:27 +01:00
|
|
|
if (This->view)
|
|
|
|
UnmapViewOfFile(This->view);
|
|
|
|
else
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->data);
|
2012-08-14 20:39:15 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BitmapImpl_GetSize(IWICBitmap *iface,
|
|
|
|
UINT *puiWidth, UINT *puiHeight)
|
|
|
|
{
|
2012-08-14 22:49:02 +02:00
|
|
|
BitmapImpl *This = impl_from_IWICBitmap(iface);
|
|
|
|
TRACE("(%p,%p,%p)\n", iface, puiWidth, puiHeight);
|
|
|
|
|
|
|
|
if (!puiWidth || !puiHeight)
|
|
|
|
return E_INVALIDARG;
|
2012-08-14 20:39:15 +02:00
|
|
|
|
2012-08-14 22:49:02 +02:00
|
|
|
*puiWidth = This->width;
|
|
|
|
*puiHeight = This->height;
|
|
|
|
|
|
|
|
return S_OK;
|
2012-08-14 20:39:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BitmapImpl_GetPixelFormat(IWICBitmap *iface,
|
|
|
|
WICPixelFormatGUID *pPixelFormat)
|
|
|
|
{
|
2012-08-14 22:39:58 +02:00
|
|
|
BitmapImpl *This = impl_from_IWICBitmap(iface);
|
|
|
|
TRACE("(%p,%p)\n", iface, pPixelFormat);
|
2012-08-14 20:39:15 +02:00
|
|
|
|
2012-08-14 22:39:58 +02:00
|
|
|
if (!pPixelFormat)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
memcpy(pPixelFormat, &This->pixelformat, sizeof(GUID));
|
|
|
|
|
|
|
|
return S_OK;
|
2012-08-14 20:39:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BitmapImpl_GetResolution(IWICBitmap *iface,
|
|
|
|
double *pDpiX, double *pDpiY)
|
|
|
|
{
|
2012-08-14 22:54:10 +02:00
|
|
|
BitmapImpl *This = impl_from_IWICBitmap(iface);
|
|
|
|
TRACE("(%p,%p,%p)\n", iface, pDpiX, pDpiY);
|
|
|
|
|
|
|
|
if (!pDpiX || !pDpiY)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->cs);
|
|
|
|
*pDpiX = This->dpix;
|
|
|
|
*pDpiY = This->dpiy;
|
|
|
|
LeaveCriticalSection(&This->cs);
|
2012-08-14 20:39:15 +02:00
|
|
|
|
2012-08-14 22:54:10 +02:00
|
|
|
return S_OK;
|
2012-08-14 20:39:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BitmapImpl_CopyPalette(IWICBitmap *iface,
|
|
|
|
IWICPalette *pIPalette)
|
|
|
|
{
|
2012-08-14 21:01:11 +02:00
|
|
|
BitmapImpl *This = impl_from_IWICBitmap(iface);
|
|
|
|
TRACE("(%p,%p)\n", iface, pIPalette);
|
2012-08-14 20:39:15 +02:00
|
|
|
|
2012-08-14 21:01:11 +02:00
|
|
|
if (!This->palette_set)
|
|
|
|
return WINCODEC_ERR_PALETTEUNAVAILABLE;
|
|
|
|
|
|
|
|
return IWICPalette_InitializeFromPalette(pIPalette, This->palette);
|
2012-08-14 20:39:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BitmapImpl_CopyPixels(IWICBitmap *iface,
|
|
|
|
const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
|
|
|
|
{
|
2012-08-14 22:36:30 +02:00
|
|
|
BitmapImpl *This = impl_from_IWICBitmap(iface);
|
2018-11-09 12:26:45 +01:00
|
|
|
TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
|
2012-08-14 20:39:15 +02:00
|
|
|
|
2012-08-14 22:36:30 +02:00
|
|
|
return copy_pixels(This->bpp, This->data, This->width, This->height,
|
|
|
|
This->stride, prc, cbStride, cbBufferSize, pbBuffer);
|
2012-08-14 20:39:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BitmapImpl_Lock(IWICBitmap *iface, const WICRect *prcLock,
|
|
|
|
DWORD flags, IWICBitmapLock **ppILock)
|
|
|
|
{
|
2012-08-14 21:50:07 +02:00
|
|
|
BitmapImpl *This = impl_from_IWICBitmap(iface);
|
|
|
|
BitmapLockImpl *result;
|
2012-08-14 22:24:58 +02:00
|
|
|
WICRect rc;
|
2012-08-14 20:39:15 +02:00
|
|
|
|
2018-11-09 12:26:45 +01:00
|
|
|
TRACE("(%p,%s,%x,%p)\n", iface, debug_wic_rect(prcLock), flags, ppILock);
|
2012-08-14 21:50:07 +02:00
|
|
|
|
|
|
|
if (!(flags & (WICBitmapLockRead|WICBitmapLockWrite)) || !ppILock)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2012-08-14 22:24:58 +02:00
|
|
|
if (!prcLock)
|
|
|
|
{
|
|
|
|
rc.X = rc.Y = 0;
|
|
|
|
rc.Width = This->width;
|
|
|
|
rc.Height = This->height;
|
|
|
|
prcLock = &rc;
|
|
|
|
}
|
|
|
|
else if (prcLock->X >= This->width || prcLock->Y >= This->height ||
|
|
|
|
prcLock->X + prcLock->Width > This->width ||
|
|
|
|
prcLock->Y + prcLock->Height > This->height ||
|
|
|
|
prcLock->Width <= 0 || prcLock->Height <= 0)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
else if (((prcLock->X * This->bpp) % 8) != 0)
|
|
|
|
{
|
|
|
|
FIXME("Cannot lock at an X coordinate not at a full byte\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2012-08-14 21:50:07 +02:00
|
|
|
result = HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapLockImpl));
|
|
|
|
if (!result)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (!BitmapImpl_AcquireLock(This, flags & WICBitmapLockWrite))
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, result);
|
|
|
|
return WINCODEC_ERR_ALREADYLOCKED;
|
|
|
|
}
|
|
|
|
|
|
|
|
result->IWICBitmapLock_iface.lpVtbl = &BitmapLockImpl_Vtbl;
|
|
|
|
result->ref = 1;
|
|
|
|
result->parent = This;
|
2012-08-14 22:24:58 +02:00
|
|
|
result->width = prcLock->Width;
|
|
|
|
result->height = prcLock->Height;
|
|
|
|
result->data = This->data + This->stride * prcLock->Y +
|
|
|
|
(This->bpp * prcLock->X)/8;
|
2012-08-14 21:50:07 +02:00
|
|
|
|
|
|
|
IWICBitmap_AddRef(&This->IWICBitmap_iface);
|
|
|
|
*ppILock = &result->IWICBitmapLock_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
2012-08-14 20:39:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BitmapImpl_SetPalette(IWICBitmap *iface, IWICPalette *pIPalette)
|
|
|
|
{
|
2012-08-14 21:01:11 +02:00
|
|
|
BitmapImpl *This = impl_from_IWICBitmap(iface);
|
|
|
|
HRESULT hr;
|
2012-08-14 20:39:15 +02:00
|
|
|
|
2012-08-14 21:01:11 +02:00
|
|
|
TRACE("(%p,%p)\n", iface, pIPalette);
|
|
|
|
|
|
|
|
if (!This->palette)
|
|
|
|
{
|
|
|
|
IWICPalette *new_palette;
|
|
|
|
hr = PaletteImpl_Create(&new_palette);
|
|
|
|
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
if (InterlockedCompareExchangePointer((void**)&This->palette, new_palette, NULL))
|
|
|
|
{
|
|
|
|
/* someone beat us to it */
|
|
|
|
IWICPalette_Release(new_palette);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IWICPalette_InitializeFromPalette(This->palette, pIPalette);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
This->palette_set = 1;
|
|
|
|
|
|
|
|
return S_OK;
|
2012-08-14 20:39:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BitmapImpl_SetResolution(IWICBitmap *iface,
|
|
|
|
double dpiX, double dpiY)
|
|
|
|
{
|
2012-08-14 22:54:10 +02:00
|
|
|
BitmapImpl *This = impl_from_IWICBitmap(iface);
|
|
|
|
TRACE("(%p,%f,%f)\n", iface, dpiX, dpiY);
|
2012-08-14 20:39:15 +02:00
|
|
|
|
2012-08-14 22:54:10 +02:00
|
|
|
EnterCriticalSection(&This->cs);
|
|
|
|
This->dpix = dpiX;
|
|
|
|
This->dpiy = dpiY;
|
|
|
|
LeaveCriticalSection(&This->cs);
|
|
|
|
|
|
|
|
return S_OK;
|
2012-08-14 20:39:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2019-05-15 05:36:20 +02:00
|
|
|
static HRESULT WINAPI IMILBitmapImpl_QueryInterface(IMILBitmap *iface, REFIID iid,
|
2013-10-14 05:07:06 +02:00
|
|
|
void **ppv)
|
|
|
|
{
|
2019-05-15 05:36:20 +02:00
|
|
|
BitmapImpl *This = impl_from_IMILBitmap(iface);
|
2013-10-14 05:07:06 +02:00
|
|
|
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
|
2019-05-15 05:36:20 +02:00
|
|
|
return IWICBitmap_QueryInterface(&This->IWICBitmap_iface, iid, ppv);
|
2013-10-14 05:07:06 +02:00
|
|
|
}
|
|
|
|
|
2019-05-15 05:36:20 +02:00
|
|
|
static ULONG WINAPI IMILBitmapImpl_AddRef(IMILBitmap *iface)
|
2013-10-14 05:07:06 +02:00
|
|
|
{
|
2019-05-15 05:36:20 +02:00
|
|
|
BitmapImpl *This = impl_from_IMILBitmap(iface);
|
2013-10-14 05:07:06 +02:00
|
|
|
return IWICBitmap_AddRef(&This->IWICBitmap_iface);
|
|
|
|
}
|
|
|
|
|
2019-05-15 05:36:20 +02:00
|
|
|
static ULONG WINAPI IMILBitmapImpl_Release(IMILBitmap *iface)
|
2013-10-14 05:07:06 +02:00
|
|
|
{
|
2019-05-15 05:36:20 +02:00
|
|
|
BitmapImpl *This = impl_from_IMILBitmap(iface);
|
2013-10-14 05:07:06 +02:00
|
|
|
return IWICBitmap_Release(&This->IWICBitmap_iface);
|
|
|
|
}
|
|
|
|
|
2019-05-15 05:36:20 +02:00
|
|
|
static HRESULT WINAPI IMILBitmapImpl_GetSize(IMILBitmap *iface,
|
2013-10-14 05:07:06 +02:00
|
|
|
UINT *width, UINT *height)
|
|
|
|
{
|
2019-05-15 05:36:20 +02:00
|
|
|
BitmapImpl *This = impl_from_IMILBitmap(iface);
|
|
|
|
TRACE("(%p,%p,%p)\n", iface, width, height);
|
2013-10-14 05:07:06 +02:00
|
|
|
return IWICBitmap_GetSize(&This->IWICBitmap_iface, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
const GUID *WIC_format;
|
|
|
|
int enum_format;
|
|
|
|
} pixel_fmt_map[] =
|
|
|
|
{
|
|
|
|
{ &GUID_WICPixelFormatDontCare, 0 },
|
|
|
|
{ &GUID_WICPixelFormat1bppIndexed, 1 },
|
|
|
|
{ &GUID_WICPixelFormat2bppIndexed, 2 },
|
|
|
|
{ &GUID_WICPixelFormat4bppIndexed, 3 },
|
|
|
|
{ &GUID_WICPixelFormat8bppIndexed, 4 },
|
|
|
|
{ &GUID_WICPixelFormatBlackWhite, 5 },
|
|
|
|
{ &GUID_WICPixelFormat2bppGray, 6 },
|
|
|
|
{ &GUID_WICPixelFormat4bppGray, 7 },
|
|
|
|
{ &GUID_WICPixelFormat8bppGray, 8 },
|
|
|
|
{ &GUID_WICPixelFormat16bppBGR555, 9 },
|
|
|
|
{ &GUID_WICPixelFormat16bppBGR565, 0x0a },
|
|
|
|
{ &GUID_WICPixelFormat16bppGray, 0x0b },
|
|
|
|
{ &GUID_WICPixelFormat24bppBGR, 0x0c },
|
|
|
|
{ &GUID_WICPixelFormat24bppRGB, 0x0d },
|
|
|
|
{ &GUID_WICPixelFormat32bppBGR, 0x0e },
|
|
|
|
{ &GUID_WICPixelFormat32bppBGRA, 0x0f },
|
|
|
|
{ &GUID_WICPixelFormat32bppPBGRA, 0x10 },
|
|
|
|
{ &GUID_WICPixelFormat48bppRGB, 0x15 },
|
|
|
|
{ &GUID_WICPixelFormat64bppRGBA, 0x16 },
|
|
|
|
{ &GUID_WICPixelFormat64bppPRGBA, 0x17 },
|
|
|
|
{ &GUID_WICPixelFormat32bppCMYK, 0x1c }
|
|
|
|
};
|
|
|
|
|
2019-05-15 05:36:20 +02:00
|
|
|
static HRESULT WINAPI IMILBitmapImpl_GetPixelFormat(IMILBitmap *iface,
|
2013-10-14 05:07:06 +02:00
|
|
|
int *format)
|
|
|
|
{
|
2019-05-15 05:36:20 +02:00
|
|
|
BitmapImpl *This = impl_from_IMILBitmap(iface);
|
2013-10-14 05:07:06 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", iface, format);
|
|
|
|
|
|
|
|
if (!format) return E_INVALIDARG;
|
|
|
|
|
|
|
|
*format = 0;
|
|
|
|
|
2018-07-18 23:01:36 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(pixel_fmt_map); i++)
|
2013-10-14 05:07:06 +02:00
|
|
|
{
|
|
|
|
if (IsEqualGUID(pixel_fmt_map[i].WIC_format, &This->pixelformat))
|
|
|
|
{
|
|
|
|
*format = pixel_fmt_map[i].enum_format;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-15 05:36:20 +02:00
|
|
|
TRACE("=> %u\n", *format);
|
2013-10-14 05:07:06 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-15 05:36:20 +02:00
|
|
|
static HRESULT WINAPI IMILBitmapImpl_GetResolution(IMILBitmap *iface,
|
2013-10-14 05:07:06 +02:00
|
|
|
double *dpix, double *dpiy)
|
|
|
|
{
|
2019-05-15 05:36:20 +02:00
|
|
|
BitmapImpl *This = impl_from_IMILBitmap(iface);
|
|
|
|
TRACE("(%p,%p,%p)\n", iface, dpix, dpiy);
|
2013-10-14 05:07:06 +02:00
|
|
|
return IWICBitmap_GetResolution(&This->IWICBitmap_iface, dpix, dpiy);
|
|
|
|
}
|
|
|
|
|
2019-05-15 05:36:20 +02:00
|
|
|
static HRESULT WINAPI IMILBitmapImpl_CopyPalette(IMILBitmap *iface,
|
2013-10-14 05:07:06 +02:00
|
|
|
IWICPalette *palette)
|
|
|
|
{
|
2019-05-15 05:36:20 +02:00
|
|
|
BitmapImpl *This = impl_from_IMILBitmap(iface);
|
|
|
|
TRACE("(%p,%p)\n", iface, palette);
|
2013-10-14 05:07:06 +02:00
|
|
|
return IWICBitmap_CopyPalette(&This->IWICBitmap_iface, palette);
|
|
|
|
}
|
|
|
|
|
2019-05-15 05:36:20 +02:00
|
|
|
static HRESULT WINAPI IMILBitmapImpl_CopyPixels(IMILBitmap *iface,
|
2013-10-14 05:07:06 +02:00
|
|
|
const WICRect *rc, UINT stride, UINT size, BYTE *buffer)
|
|
|
|
{
|
2019-05-15 05:36:20 +02:00
|
|
|
BitmapImpl *This = impl_from_IMILBitmap(iface);
|
|
|
|
TRACE("(%p,%p,%u,%u,%p)\n", iface, rc, stride, size, buffer);
|
2013-10-14 05:07:06 +02:00
|
|
|
return IWICBitmap_CopyPixels(&This->IWICBitmap_iface, rc, stride, size, buffer);
|
|
|
|
}
|
|
|
|
|
2019-05-15 05:36:20 +02:00
|
|
|
static HRESULT WINAPI IMILBitmapImpl_unknown1(IMILBitmap *iface, void **ppv)
|
2013-10-14 05:07:06 +02:00
|
|
|
{
|
2019-05-15 05:36:20 +02:00
|
|
|
BitmapImpl *This = impl_from_IMILBitmap(iface);
|
2013-10-14 05:07:06 +02:00
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", iface, ppv);
|
|
|
|
|
|
|
|
if (!ppv) return E_INVALIDARG;
|
|
|
|
|
2019-05-15 05:36:20 +02:00
|
|
|
/* reference count is not incremented here */
|
2013-10-14 05:07:06 +02:00
|
|
|
*ppv = &This->IMILUnknown1_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-15 05:36:20 +02:00
|
|
|
static HRESULT WINAPI IMILBitmapImpl_Lock(IMILBitmap *iface, const WICRect *rc, DWORD flags, IWICBitmapLock **lock)
|
|
|
|
{
|
|
|
|
BitmapImpl *This = impl_from_IMILBitmap(iface);
|
|
|
|
TRACE("(%p,%p,%08x,%p)\n", iface, rc, flags, lock);
|
|
|
|
return IWICBitmap_Lock(&This->IWICBitmap_iface, rc, flags, lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IMILBitmapImpl_Unlock(IMILBitmap *iface, IWICBitmapLock *lock)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%p)\n", iface, lock);
|
|
|
|
IWICBitmapLock_Release(lock);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IMILBitmapImpl_SetPalette(IMILBitmap *iface, IWICPalette *palette)
|
|
|
|
{
|
|
|
|
BitmapImpl *This = impl_from_IMILBitmap(iface);
|
|
|
|
TRACE("(%p,%p)\n", iface, palette);
|
|
|
|
return IWICBitmap_SetPalette(&This->IWICBitmap_iface, palette);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IMILBitmapImpl_SetResolution(IMILBitmap *iface, double dpix, double dpiy)
|
|
|
|
{
|
|
|
|
BitmapImpl *This = impl_from_IMILBitmap(iface);
|
|
|
|
TRACE("(%p,%f,%f)\n", iface, dpix, dpiy);
|
|
|
|
return IWICBitmap_SetResolution(&This->IWICBitmap_iface, dpix, dpiy);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IMILBitmapImpl_AddDirtyRect(IMILBitmap *iface, const WICRect *rc)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%p): stub\n", iface, rc);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMILBitmapVtbl IMILBitmapImpl_Vtbl =
|
2013-10-14 05:07:06 +02:00
|
|
|
{
|
|
|
|
IMILBitmapImpl_QueryInterface,
|
|
|
|
IMILBitmapImpl_AddRef,
|
|
|
|
IMILBitmapImpl_Release,
|
|
|
|
IMILBitmapImpl_GetSize,
|
|
|
|
IMILBitmapImpl_GetPixelFormat,
|
|
|
|
IMILBitmapImpl_GetResolution,
|
|
|
|
IMILBitmapImpl_CopyPalette,
|
|
|
|
IMILBitmapImpl_CopyPixels,
|
2019-05-15 05:36:20 +02:00
|
|
|
IMILBitmapImpl_unknown1,
|
|
|
|
IMILBitmapImpl_Lock,
|
|
|
|
IMILBitmapImpl_Unlock,
|
|
|
|
IMILBitmapImpl_SetPalette,
|
|
|
|
IMILBitmapImpl_SetResolution,
|
|
|
|
IMILBitmapImpl_AddDirtyRect
|
2013-10-14 05:07:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI IMILUnknown1Impl_QueryInterface(IMILUnknown1 *iface, REFIID iid,
|
|
|
|
void **ppv)
|
|
|
|
{
|
2019-05-15 05:36:20 +02:00
|
|
|
/* It's not clear what interface should be returned here */
|
|
|
|
FIXME("(%p,%s,%p): stub\n", iface, debugstr_guid(iid), ppv);
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
2013-10-14 05:07:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IMILUnknown1Impl_AddRef(IMILUnknown1 *iface)
|
|
|
|
{
|
|
|
|
BitmapImpl *This = impl_from_IMILUnknown1(iface);
|
|
|
|
return IWICBitmap_AddRef(&This->IWICBitmap_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IMILUnknown1Impl_Release(IMILUnknown1 *iface)
|
|
|
|
{
|
|
|
|
BitmapImpl *This = impl_from_IMILUnknown1(iface);
|
|
|
|
return IWICBitmap_Release(&This->IWICBitmap_iface);
|
|
|
|
}
|
|
|
|
|
2019-05-15 05:36:20 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(IMILUnknown1Impl_unknown1, 8)
|
|
|
|
DECLSPEC_HIDDEN void __thiscall IMILUnknown1Impl_unknown1(IMILUnknown1 *iface, void *arg)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%p): stub\n", iface, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IMILUnknown1Impl_unknown2(IMILUnknown1 *iface, void *arg1, void *arg2)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%p,%p): stub\n", iface, arg1, arg2);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(IMILUnknown1Impl_unknown3, 8)
|
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall IMILUnknown1Impl_unknown3(IMILUnknown1 *iface, void *arg)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%p): stub\n", iface, arg);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IMILUnknown1Impl_unknown4(IMILUnknown1 *iface, void *arg)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%p): stub\n", iface, arg);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IMILUnknown1Impl_unknown5(IMILUnknown1 *iface, void *arg)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%p): stub\n", iface, arg);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IMILUnknown1Impl_unknown6(IMILUnknown1 *iface, DWORD64 arg)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%s): stub\n", iface, wine_dbgstr_longlong(arg));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IMILUnknown1Impl_unknown7(IMILUnknown1 *iface, void *arg)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%p): stub\n", iface, arg);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(IMILUnknown1Impl_unknown8, 4)
|
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall IMILUnknown1Impl_unknown8(IMILUnknown1 *iface)
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", iface);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-10-14 05:07:06 +02:00
|
|
|
static const IMILUnknown1Vtbl IMILUnknown1Impl_Vtbl =
|
|
|
|
{
|
|
|
|
IMILUnknown1Impl_QueryInterface,
|
|
|
|
IMILUnknown1Impl_AddRef,
|
|
|
|
IMILUnknown1Impl_Release,
|
2019-05-15 05:36:20 +02:00
|
|
|
THISCALL(IMILUnknown1Impl_unknown1),
|
|
|
|
IMILUnknown1Impl_unknown2,
|
|
|
|
THISCALL(IMILUnknown1Impl_unknown3),
|
|
|
|
IMILUnknown1Impl_unknown4,
|
|
|
|
IMILUnknown1Impl_unknown5,
|
|
|
|
IMILUnknown1Impl_unknown6,
|
|
|
|
IMILUnknown1Impl_unknown7,
|
|
|
|
THISCALL(IMILUnknown1Impl_unknown8)
|
2013-10-14 05:07:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI IMILUnknown2Impl_QueryInterface(IMILUnknown2 *iface, REFIID iid,
|
|
|
|
void **ppv)
|
|
|
|
{
|
2019-05-15 05:36:20 +02:00
|
|
|
FIXME("(%p,%s,%p): stub\n", iface, debugstr_guid(iid), ppv);
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
2013-10-14 05:07:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IMILUnknown2Impl_AddRef(IMILUnknown2 *iface)
|
|
|
|
{
|
2019-05-15 05:36:20 +02:00
|
|
|
FIXME("(%p): stub\n", iface);
|
|
|
|
return 0;
|
2013-10-14 05:07:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IMILUnknown2Impl_Release(IMILUnknown2 *iface)
|
|
|
|
{
|
2019-05-15 05:36:20 +02:00
|
|
|
FIXME("(%p): stub\n", iface);
|
|
|
|
return 0;
|
2013-10-14 05:07:06 +02:00
|
|
|
}
|
|
|
|
|
2019-05-15 05:36:20 +02:00
|
|
|
static HRESULT WINAPI IMILUnknown2Impl_unknown1(IMILUnknown2 *iface, void *arg1, void **arg2)
|
2013-10-14 05:07:06 +02:00
|
|
|
{
|
|
|
|
FIXME("(%p,%p,%p): stub\n", iface, arg1, arg2);
|
2019-05-15 05:36:20 +02:00
|
|
|
if (arg2) *arg2 = NULL;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IMILUnknown2Impl_unknown2(IMILUnknown2 *iface, void *arg1, void *arg2)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%p,%p): stub\n", iface, arg1, arg2);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IMILUnknown2Impl_unknown3(IMILUnknown2 *iface, void *arg1)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%p): stub\n", iface, arg1);
|
2013-10-14 05:07:06 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMILUnknown2Vtbl IMILUnknown2Impl_Vtbl =
|
|
|
|
{
|
|
|
|
IMILUnknown2Impl_QueryInterface,
|
|
|
|
IMILUnknown2Impl_AddRef,
|
|
|
|
IMILUnknown2Impl_Release,
|
2019-05-15 05:36:20 +02:00
|
|
|
IMILUnknown2Impl_unknown1,
|
|
|
|
IMILUnknown2Impl_unknown2,
|
|
|
|
IMILUnknown2Impl_unknown3
|
2013-10-14 05:07:06 +02:00
|
|
|
};
|
|
|
|
|
2018-03-21 10:28:27 +01:00
|
|
|
HRESULT BitmapImpl_Create(UINT uiWidth, UINT uiHeight, UINT stride, UINT datasize, void *view,
|
|
|
|
UINT offset, REFWICPixelFormatGUID pixelFormat, WICBitmapCreateCacheOption option,
|
2012-08-14 20:39:15 +02:00
|
|
|
IWICBitmap **ppIBitmap)
|
|
|
|
{
|
2012-08-14 22:24:58 +02:00
|
|
|
HRESULT hr;
|
2012-08-14 20:39:15 +02:00
|
|
|
BitmapImpl *This;
|
2012-08-14 22:24:58 +02:00
|
|
|
BYTE *data;
|
2013-01-04 11:05:30 +01:00
|
|
|
UINT bpp;
|
2012-08-14 22:24:58 +02:00
|
|
|
|
|
|
|
hr = get_pixelformat_bpp(pixelFormat, &bpp);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
2013-01-04 11:05:30 +01:00
|
|
|
if (!stride) stride = (((bpp*uiWidth)+31)/32)*4;
|
|
|
|
if (!datasize) datasize = stride * uiHeight;
|
|
|
|
|
|
|
|
if (datasize < stride * uiHeight) return WINCODEC_ERR_INSUFFICIENTBUFFER;
|
|
|
|
if (stride < ((bpp*uiWidth)+7)/8) return E_INVALIDARG;
|
2012-08-14 20:39:15 +02:00
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapImpl));
|
2018-03-21 10:28:27 +01:00
|
|
|
if (!This) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (view) data = (BYTE *)view + offset;
|
|
|
|
else if (!(data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, datasize)))
|
2012-08-14 22:24:58 +02:00
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2012-08-14 20:39:15 +02:00
|
|
|
|
|
|
|
This->IWICBitmap_iface.lpVtbl = &BitmapImpl_Vtbl;
|
2019-05-15 05:36:20 +02:00
|
|
|
This->IMILBitmap_iface.lpVtbl = &IMILBitmapImpl_Vtbl;
|
2013-10-14 05:07:06 +02:00
|
|
|
This->IMILUnknown1_iface.lpVtbl = &IMILUnknown1Impl_Vtbl;
|
|
|
|
This->IMILUnknown2_iface.lpVtbl = &IMILUnknown2Impl_Vtbl;
|
2012-08-14 20:39:15 +02:00
|
|
|
This->ref = 1;
|
2012-08-14 21:01:11 +02:00
|
|
|
This->palette = NULL;
|
|
|
|
This->palette_set = 0;
|
2012-08-14 21:50:07 +02:00
|
|
|
This->lock = 0;
|
2012-08-14 22:24:58 +02:00
|
|
|
This->data = data;
|
2018-03-21 10:28:27 +01:00
|
|
|
This->view = view;
|
|
|
|
This->offset = offset;
|
2012-08-14 22:24:58 +02:00
|
|
|
This->width = uiWidth;
|
|
|
|
This->height = uiHeight;
|
|
|
|
This->stride = stride;
|
|
|
|
This->bpp = bpp;
|
2012-08-14 22:39:58 +02:00
|
|
|
memcpy(&This->pixelformat, pixelFormat, sizeof(GUID));
|
2012-08-14 22:54:10 +02:00
|
|
|
This->dpix = This->dpiy = 0.0;
|
|
|
|
InitializeCriticalSection(&This->cs);
|
|
|
|
This->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": BitmapImpl.lock");
|
2012-08-14 20:39:15 +02:00
|
|
|
|
|
|
|
*ppIBitmap = &This->IWICBitmap_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|