2 * Copyright 2012 Vincent Povirk for CodeWeavers
3 * Copyright 2016 Dmitry Timoshkov
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "wincodecs_private.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs
);
35 /* WARNING: .NET Media Integration Layer (MIL) directly dereferences
36 * BitmapImpl members and depends on its exact layout.
38 typedef struct BitmapImpl
{
39 IMILUnknown1 IMILUnknown1_iface
;
41 IMILBitmap IMILBitmap_iface
;
42 IWICBitmap IWICBitmap_iface
;
43 IMILUnknown2 IMILUnknown2_iface
;
46 LONG lock
; /* 0 if not locked, -1 if locked for writing, count if locked for reading */
48 void *view
; /* used if data is a section created by an application */
49 UINT offset
; /* offset into view */
53 WICPixelFormatGUID pixelformat
;
58 typedef struct BitmapLockImpl
{
59 IWICBitmapLock IWICBitmapLock_iface
;
66 static inline BitmapImpl
*impl_from_IWICBitmap(IWICBitmap
*iface
)
68 return CONTAINING_RECORD(iface
, BitmapImpl
, IWICBitmap_iface
);
71 static inline BitmapImpl
*impl_from_IMILBitmap(IMILBitmap
*iface
)
73 return CONTAINING_RECORD(iface
, BitmapImpl
, IMILBitmap_iface
);
76 static inline BitmapImpl
*impl_from_IMILUnknown1(IMILUnknown1
*iface
)
78 return CONTAINING_RECORD(iface
, BitmapImpl
, IMILUnknown1_iface
);
81 static inline BitmapLockImpl
*impl_from_IWICBitmapLock(IWICBitmapLock
*iface
)
83 return CONTAINING_RECORD(iface
, BitmapLockImpl
, IWICBitmapLock_iface
);
86 static BOOL
BitmapImpl_AcquireLock(BitmapImpl
*This
, int write
)
90 return 0 == InterlockedCompareExchange(&This
->lock
, -1, 0);
96 LONG prev_val
= This
->lock
;
99 if (prev_val
== InterlockedCompareExchange(&This
->lock
, prev_val
+1, prev_val
))
105 static void BitmapImpl_ReleaseLock(BitmapImpl
*This
)
109 LONG prev_val
= This
->lock
, new_val
;
113 new_val
= prev_val
- 1;
114 if (prev_val
== InterlockedCompareExchange(&This
->lock
, new_val
, prev_val
))
120 static HRESULT WINAPI
BitmapLockImpl_QueryInterface(IWICBitmapLock
*iface
, REFIID iid
,
123 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
124 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
126 if (!ppv
) return E_INVALIDARG
;
128 if (IsEqualIID(&IID_IUnknown
, iid
) ||
129 IsEqualIID(&IID_IWICBitmapLock
, iid
))
131 *ppv
= &This
->IWICBitmapLock_iface
;
135 FIXME("unknown interface %s\n", debugstr_guid(iid
));
137 return E_NOINTERFACE
;
140 IUnknown_AddRef((IUnknown
*)*ppv
);
144 static ULONG WINAPI
BitmapLockImpl_AddRef(IWICBitmapLock
*iface
)
146 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
147 ULONG ref
= InterlockedIncrement(&This
->ref
);
149 TRACE("(%p) refcount=%u\n", iface
, ref
);
154 static ULONG WINAPI
BitmapLockImpl_Release(IWICBitmapLock
*iface
)
156 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
157 ULONG ref
= InterlockedDecrement(&This
->ref
);
159 TRACE("(%p) refcount=%u\n", iface
, ref
);
163 BitmapImpl_ReleaseLock(This
->parent
);
164 IWICBitmap_Release(&This
->parent
->IWICBitmap_iface
);
165 HeapFree(GetProcessHeap(), 0, This
);
171 static HRESULT WINAPI
BitmapLockImpl_GetSize(IWICBitmapLock
*iface
,
172 UINT
*puiWidth
, UINT
*puiHeight
)
174 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
175 TRACE("(%p,%p,%p)\n", iface
, puiWidth
, puiHeight
);
177 if (!puiWidth
|| !puiHeight
)
180 *puiWidth
= This
->width
;
181 *puiHeight
= This
->height
;
186 static HRESULT WINAPI
BitmapLockImpl_GetStride(IWICBitmapLock
*iface
,
189 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
190 TRACE("(%p,%p)\n", iface
, pcbStride
);
195 *pcbStride
= This
->parent
->stride
;
200 static HRESULT WINAPI
BitmapLockImpl_GetDataPointer(IWICBitmapLock
*iface
,
201 UINT
*pcbBufferSize
, BYTE
**ppbData
)
203 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
204 TRACE("(%p,%p,%p)\n", iface
, pcbBufferSize
, ppbData
);
206 if (!pcbBufferSize
|| !ppbData
)
209 *pcbBufferSize
= This
->parent
->stride
* (This
->height
- 1) +
210 ((This
->parent
->bpp
* This
->width
) + 7)/8;
211 *ppbData
= This
->data
;
216 static HRESULT WINAPI
BitmapLockImpl_GetPixelFormat(IWICBitmapLock
*iface
,
217 WICPixelFormatGUID
*pPixelFormat
)
219 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
220 TRACE("(%p,%p)\n", iface
, pPixelFormat
);
222 return IWICBitmap_GetPixelFormat(&This
->parent
->IWICBitmap_iface
, pPixelFormat
);
225 static const IWICBitmapLockVtbl BitmapLockImpl_Vtbl
= {
226 BitmapLockImpl_QueryInterface
,
227 BitmapLockImpl_AddRef
,
228 BitmapLockImpl_Release
,
229 BitmapLockImpl_GetSize
,
230 BitmapLockImpl_GetStride
,
231 BitmapLockImpl_GetDataPointer
,
232 BitmapLockImpl_GetPixelFormat
235 static HRESULT WINAPI
BitmapImpl_QueryInterface(IWICBitmap
*iface
, REFIID iid
,
238 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
239 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
241 if (!ppv
) return E_INVALIDARG
;
243 if (IsEqualIID(&IID_IUnknown
, iid
) ||
244 IsEqualIID(&IID_IWICBitmapSource
, iid
) ||
245 IsEqualIID(&IID_IWICBitmap
, iid
))
247 *ppv
= &This
->IWICBitmap_iface
;
249 else if (IsEqualIID(&IID_IMILBitmap
, iid
) ||
250 IsEqualIID(&IID_IMILBitmapSource
, iid
))
252 *ppv
= &This
->IMILBitmap_iface
;
256 FIXME("unknown interface %s\n", debugstr_guid(iid
));
258 return E_NOINTERFACE
;
261 IUnknown_AddRef((IUnknown
*)*ppv
);
265 static ULONG WINAPI
BitmapImpl_AddRef(IWICBitmap
*iface
)
267 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
268 ULONG ref
= InterlockedIncrement(&This
->ref
);
270 TRACE("(%p) refcount=%u\n", iface
, ref
);
275 static ULONG WINAPI
BitmapImpl_Release(IWICBitmap
*iface
)
277 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
278 ULONG ref
= InterlockedDecrement(&This
->ref
);
280 TRACE("(%p) refcount=%u\n", iface
, ref
);
284 if (This
->palette
) IWICPalette_Release(This
->palette
);
285 This
->cs
.DebugInfo
->Spare
[0] = 0;
286 DeleteCriticalSection(&This
->cs
);
288 UnmapViewOfFile(This
->view
);
290 HeapFree(GetProcessHeap(), 0, This
->data
);
291 HeapFree(GetProcessHeap(), 0, This
);
297 static HRESULT WINAPI
BitmapImpl_GetSize(IWICBitmap
*iface
,
298 UINT
*puiWidth
, UINT
*puiHeight
)
300 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
301 TRACE("(%p,%p,%p)\n", iface
, puiWidth
, puiHeight
);
303 if (!puiWidth
|| !puiHeight
)
306 *puiWidth
= This
->width
;
307 *puiHeight
= This
->height
;
312 static HRESULT WINAPI
BitmapImpl_GetPixelFormat(IWICBitmap
*iface
,
313 WICPixelFormatGUID
*pPixelFormat
)
315 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
316 TRACE("(%p,%p)\n", iface
, pPixelFormat
);
321 memcpy(pPixelFormat
, &This
->pixelformat
, sizeof(GUID
));
326 static HRESULT WINAPI
BitmapImpl_GetResolution(IWICBitmap
*iface
,
327 double *pDpiX
, double *pDpiY
)
329 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
330 TRACE("(%p,%p,%p)\n", iface
, pDpiX
, pDpiY
);
332 if (!pDpiX
|| !pDpiY
)
335 EnterCriticalSection(&This
->cs
);
338 LeaveCriticalSection(&This
->cs
);
343 static HRESULT WINAPI
BitmapImpl_CopyPalette(IWICBitmap
*iface
,
344 IWICPalette
*pIPalette
)
346 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
347 TRACE("(%p,%p)\n", iface
, pIPalette
);
349 if (!This
->palette_set
)
350 return WINCODEC_ERR_PALETTEUNAVAILABLE
;
352 return IWICPalette_InitializeFromPalette(pIPalette
, This
->palette
);
355 static HRESULT WINAPI
BitmapImpl_CopyPixels(IWICBitmap
*iface
,
356 const WICRect
*prc
, UINT cbStride
, UINT cbBufferSize
, BYTE
*pbBuffer
)
358 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
359 TRACE("(%p,%s,%u,%u,%p)\n", iface
, debug_wic_rect(prc
), cbStride
, cbBufferSize
, pbBuffer
);
361 return copy_pixels(This
->bpp
, This
->data
, This
->width
, This
->height
,
362 This
->stride
, prc
, cbStride
, cbBufferSize
, pbBuffer
);
365 static HRESULT WINAPI
BitmapImpl_Lock(IWICBitmap
*iface
, const WICRect
*prcLock
,
366 DWORD flags
, IWICBitmapLock
**ppILock
)
368 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
369 BitmapLockImpl
*result
;
372 TRACE("(%p,%s,%x,%p)\n", iface
, debug_wic_rect(prcLock
), flags
, ppILock
);
374 if (!(flags
& (WICBitmapLockRead
|WICBitmapLockWrite
)) || !ppILock
)
380 rc
.Width
= This
->width
;
381 rc
.Height
= This
->height
;
384 else if (prcLock
->X
>= This
->width
|| prcLock
->Y
>= This
->height
||
385 prcLock
->X
+ prcLock
->Width
> This
->width
||
386 prcLock
->Y
+ prcLock
->Height
> This
->height
||
387 prcLock
->Width
<= 0 || prcLock
->Height
<= 0)
389 else if (((prcLock
->X
* This
->bpp
) % 8) != 0)
391 FIXME("Cannot lock at an X coordinate not at a full byte\n");
395 result
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapLockImpl
));
397 return E_OUTOFMEMORY
;
399 if (!BitmapImpl_AcquireLock(This
, flags
& WICBitmapLockWrite
))
401 HeapFree(GetProcessHeap(), 0, result
);
402 return WINCODEC_ERR_ALREADYLOCKED
;
405 result
->IWICBitmapLock_iface
.lpVtbl
= &BitmapLockImpl_Vtbl
;
407 result
->parent
= This
;
408 result
->width
= prcLock
->Width
;
409 result
->height
= prcLock
->Height
;
410 result
->data
= This
->data
+ This
->stride
* prcLock
->Y
+
411 (This
->bpp
* prcLock
->X
)/8;
413 IWICBitmap_AddRef(&This
->IWICBitmap_iface
);
414 *ppILock
= &result
->IWICBitmapLock_iface
;
419 static HRESULT WINAPI
BitmapImpl_SetPalette(IWICBitmap
*iface
, IWICPalette
*pIPalette
)
421 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
424 TRACE("(%p,%p)\n", iface
, pIPalette
);
428 IWICPalette
*new_palette
;
429 hr
= PaletteImpl_Create(&new_palette
);
431 if (FAILED(hr
)) return hr
;
433 if (InterlockedCompareExchangePointer((void**)&This
->palette
, new_palette
, NULL
))
435 /* someone beat us to it */
436 IWICPalette_Release(new_palette
);
440 hr
= IWICPalette_InitializeFromPalette(This
->palette
, pIPalette
);
443 This
->palette_set
= 1;
448 static HRESULT WINAPI
BitmapImpl_SetResolution(IWICBitmap
*iface
,
449 double dpiX
, double dpiY
)
451 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
452 TRACE("(%p,%f,%f)\n", iface
, dpiX
, dpiY
);
454 EnterCriticalSection(&This
->cs
);
457 LeaveCriticalSection(&This
->cs
);
462 static const IWICBitmapVtbl BitmapImpl_Vtbl
= {
463 BitmapImpl_QueryInterface
,
467 BitmapImpl_GetPixelFormat
,
468 BitmapImpl_GetResolution
,
469 BitmapImpl_CopyPalette
,
470 BitmapImpl_CopyPixels
,
472 BitmapImpl_SetPalette
,
473 BitmapImpl_SetResolution
476 static HRESULT WINAPI
IMILBitmapImpl_QueryInterface(IMILBitmap
*iface
, REFIID iid
,
479 BitmapImpl
*This
= impl_from_IMILBitmap(iface
);
480 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
481 return IWICBitmap_QueryInterface(&This
->IWICBitmap_iface
, iid
, ppv
);
484 static ULONG WINAPI
IMILBitmapImpl_AddRef(IMILBitmap
*iface
)
486 BitmapImpl
*This
= impl_from_IMILBitmap(iface
);
487 return IWICBitmap_AddRef(&This
->IWICBitmap_iface
);
490 static ULONG WINAPI
IMILBitmapImpl_Release(IMILBitmap
*iface
)
492 BitmapImpl
*This
= impl_from_IMILBitmap(iface
);
493 return IWICBitmap_Release(&This
->IWICBitmap_iface
);
496 static HRESULT WINAPI
IMILBitmapImpl_GetSize(IMILBitmap
*iface
,
497 UINT
*width
, UINT
*height
)
499 BitmapImpl
*This
= impl_from_IMILBitmap(iface
);
500 TRACE("(%p,%p,%p)\n", iface
, width
, height
);
501 return IWICBitmap_GetSize(&This
->IWICBitmap_iface
, width
, height
);
506 const GUID
*WIC_format
;
510 { &GUID_WICPixelFormatDontCare
, 0 },
511 { &GUID_WICPixelFormat1bppIndexed
, 1 },
512 { &GUID_WICPixelFormat2bppIndexed
, 2 },
513 { &GUID_WICPixelFormat4bppIndexed
, 3 },
514 { &GUID_WICPixelFormat8bppIndexed
, 4 },
515 { &GUID_WICPixelFormatBlackWhite
, 5 },
516 { &GUID_WICPixelFormat2bppGray
, 6 },
517 { &GUID_WICPixelFormat4bppGray
, 7 },
518 { &GUID_WICPixelFormat8bppGray
, 8 },
519 { &GUID_WICPixelFormat16bppBGR555
, 9 },
520 { &GUID_WICPixelFormat16bppBGR565
, 0x0a },
521 { &GUID_WICPixelFormat16bppGray
, 0x0b },
522 { &GUID_WICPixelFormat24bppBGR
, 0x0c },
523 { &GUID_WICPixelFormat24bppRGB
, 0x0d },
524 { &GUID_WICPixelFormat32bppBGR
, 0x0e },
525 { &GUID_WICPixelFormat32bppBGRA
, 0x0f },
526 { &GUID_WICPixelFormat32bppPBGRA
, 0x10 },
527 { &GUID_WICPixelFormat48bppRGB
, 0x15 },
528 { &GUID_WICPixelFormat64bppRGBA
, 0x16 },
529 { &GUID_WICPixelFormat64bppPRGBA
, 0x17 },
530 { &GUID_WICPixelFormat32bppCMYK
, 0x1c }
533 static HRESULT WINAPI
IMILBitmapImpl_GetPixelFormat(IMILBitmap
*iface
,
536 BitmapImpl
*This
= impl_from_IMILBitmap(iface
);
539 TRACE("(%p,%p)\n", iface
, format
);
541 if (!format
) return E_INVALIDARG
;
545 for (i
= 0; i
< ARRAY_SIZE(pixel_fmt_map
); i
++)
547 if (IsEqualGUID(pixel_fmt_map
[i
].WIC_format
, &This
->pixelformat
))
549 *format
= pixel_fmt_map
[i
].enum_format
;
554 TRACE("=> %u\n", *format
);
558 static HRESULT WINAPI
IMILBitmapImpl_GetResolution(IMILBitmap
*iface
,
559 double *dpix
, double *dpiy
)
561 BitmapImpl
*This
= impl_from_IMILBitmap(iface
);
562 TRACE("(%p,%p,%p)\n", iface
, dpix
, dpiy
);
563 return IWICBitmap_GetResolution(&This
->IWICBitmap_iface
, dpix
, dpiy
);
566 static HRESULT WINAPI
IMILBitmapImpl_CopyPalette(IMILBitmap
*iface
,
567 IWICPalette
*palette
)
569 BitmapImpl
*This
= impl_from_IMILBitmap(iface
);
570 TRACE("(%p,%p)\n", iface
, palette
);
571 return IWICBitmap_CopyPalette(&This
->IWICBitmap_iface
, palette
);
574 static HRESULT WINAPI
IMILBitmapImpl_CopyPixels(IMILBitmap
*iface
,
575 const WICRect
*rc
, UINT stride
, UINT size
, BYTE
*buffer
)
577 BitmapImpl
*This
= impl_from_IMILBitmap(iface
);
578 TRACE("(%p,%p,%u,%u,%p)\n", iface
, rc
, stride
, size
, buffer
);
579 return IWICBitmap_CopyPixels(&This
->IWICBitmap_iface
, rc
, stride
, size
, buffer
);
582 static HRESULT WINAPI
IMILBitmapImpl_unknown1(IMILBitmap
*iface
, void **ppv
)
584 BitmapImpl
*This
= impl_from_IMILBitmap(iface
);
586 TRACE("(%p,%p)\n", iface
, ppv
);
588 if (!ppv
) return E_INVALIDARG
;
590 /* reference count is not incremented here */
591 *ppv
= &This
->IMILUnknown1_iface
;
596 static HRESULT WINAPI
IMILBitmapImpl_Lock(IMILBitmap
*iface
, const WICRect
*rc
, DWORD flags
, IWICBitmapLock
**lock
)
598 BitmapImpl
*This
= impl_from_IMILBitmap(iface
);
599 TRACE("(%p,%p,%08x,%p)\n", iface
, rc
, flags
, lock
);
600 return IWICBitmap_Lock(&This
->IWICBitmap_iface
, rc
, flags
, lock
);
603 static HRESULT WINAPI
IMILBitmapImpl_Unlock(IMILBitmap
*iface
, IWICBitmapLock
*lock
)
605 TRACE("(%p,%p)\n", iface
, lock
);
606 IWICBitmapLock_Release(lock
);
610 static HRESULT WINAPI
IMILBitmapImpl_SetPalette(IMILBitmap
*iface
, IWICPalette
*palette
)
612 BitmapImpl
*This
= impl_from_IMILBitmap(iface
);
613 TRACE("(%p,%p)\n", iface
, palette
);
614 return IWICBitmap_SetPalette(&This
->IWICBitmap_iface
, palette
);
617 static HRESULT WINAPI
IMILBitmapImpl_SetResolution(IMILBitmap
*iface
, double dpix
, double dpiy
)
619 BitmapImpl
*This
= impl_from_IMILBitmap(iface
);
620 TRACE("(%p,%f,%f)\n", iface
, dpix
, dpiy
);
621 return IWICBitmap_SetResolution(&This
->IWICBitmap_iface
, dpix
, dpiy
);
624 static HRESULT WINAPI
IMILBitmapImpl_AddDirtyRect(IMILBitmap
*iface
, const WICRect
*rc
)
626 FIXME("(%p,%p): stub\n", iface
, rc
);
630 static const IMILBitmapVtbl IMILBitmapImpl_Vtbl
=
632 IMILBitmapImpl_QueryInterface
,
633 IMILBitmapImpl_AddRef
,
634 IMILBitmapImpl_Release
,
635 IMILBitmapImpl_GetSize
,
636 IMILBitmapImpl_GetPixelFormat
,
637 IMILBitmapImpl_GetResolution
,
638 IMILBitmapImpl_CopyPalette
,
639 IMILBitmapImpl_CopyPixels
,
640 IMILBitmapImpl_unknown1
,
642 IMILBitmapImpl_Unlock
,
643 IMILBitmapImpl_SetPalette
,
644 IMILBitmapImpl_SetResolution
,
645 IMILBitmapImpl_AddDirtyRect
648 static HRESULT WINAPI
IMILUnknown1Impl_QueryInterface(IMILUnknown1
*iface
, REFIID iid
,
651 /* It's not clear what interface should be returned here */
652 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_guid(iid
), ppv
);
654 return E_NOINTERFACE
;
657 static ULONG WINAPI
IMILUnknown1Impl_AddRef(IMILUnknown1
*iface
)
659 BitmapImpl
*This
= impl_from_IMILUnknown1(iface
);
660 return IWICBitmap_AddRef(&This
->IWICBitmap_iface
);
663 static ULONG WINAPI
IMILUnknown1Impl_Release(IMILUnknown1
*iface
)
665 BitmapImpl
*This
= impl_from_IMILUnknown1(iface
);
666 return IWICBitmap_Release(&This
->IWICBitmap_iface
);
669 DEFINE_THISCALL_WRAPPER(IMILUnknown1Impl_unknown1
, 8)
670 DECLSPEC_HIDDEN
void __thiscall
IMILUnknown1Impl_unknown1(IMILUnknown1
*iface
, void *arg
)
672 FIXME("(%p,%p): stub\n", iface
, arg
);
675 static HRESULT WINAPI
IMILUnknown1Impl_unknown2(IMILUnknown1
*iface
, void *arg1
, void *arg2
)
677 FIXME("(%p,%p,%p): stub\n", iface
, arg1
, arg2
);
681 DEFINE_THISCALL_WRAPPER(IMILUnknown1Impl_unknown3
, 8)
682 DECLSPEC_HIDDEN HRESULT __thiscall
IMILUnknown1Impl_unknown3(IMILUnknown1
*iface
, void *arg
)
684 FIXME("(%p,%p): stub\n", iface
, arg
);
688 static HRESULT WINAPI
IMILUnknown1Impl_unknown4(IMILUnknown1
*iface
, void *arg
)
690 FIXME("(%p,%p): stub\n", iface
, arg
);
694 static HRESULT WINAPI
IMILUnknown1Impl_unknown5(IMILUnknown1
*iface
, void *arg
)
696 FIXME("(%p,%p): stub\n", iface
, arg
);
700 static HRESULT WINAPI
IMILUnknown1Impl_unknown6(IMILUnknown1
*iface
, DWORD64 arg
)
702 FIXME("(%p,%s): stub\n", iface
, wine_dbgstr_longlong(arg
));
706 static HRESULT WINAPI
IMILUnknown1Impl_unknown7(IMILUnknown1
*iface
, void *arg
)
708 FIXME("(%p,%p): stub\n", iface
, arg
);
712 DEFINE_THISCALL_WRAPPER(IMILUnknown1Impl_unknown8
, 4)
713 DECLSPEC_HIDDEN HRESULT __thiscall
IMILUnknown1Impl_unknown8(IMILUnknown1
*iface
)
715 FIXME("(%p): stub\n", iface
);
719 static const IMILUnknown1Vtbl IMILUnknown1Impl_Vtbl
=
721 IMILUnknown1Impl_QueryInterface
,
722 IMILUnknown1Impl_AddRef
,
723 IMILUnknown1Impl_Release
,
724 THISCALL(IMILUnknown1Impl_unknown1
),
725 IMILUnknown1Impl_unknown2
,
726 THISCALL(IMILUnknown1Impl_unknown3
),
727 IMILUnknown1Impl_unknown4
,
728 IMILUnknown1Impl_unknown5
,
729 IMILUnknown1Impl_unknown6
,
730 IMILUnknown1Impl_unknown7
,
731 THISCALL(IMILUnknown1Impl_unknown8
)
734 static HRESULT WINAPI
IMILUnknown2Impl_QueryInterface(IMILUnknown2
*iface
, REFIID iid
,
737 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_guid(iid
), ppv
);
739 return E_NOINTERFACE
;
742 static ULONG WINAPI
IMILUnknown2Impl_AddRef(IMILUnknown2
*iface
)
744 FIXME("(%p): stub\n", iface
);
748 static ULONG WINAPI
IMILUnknown2Impl_Release(IMILUnknown2
*iface
)
750 FIXME("(%p): stub\n", iface
);
754 static HRESULT WINAPI
IMILUnknown2Impl_unknown1(IMILUnknown2
*iface
, void *arg1
, void **arg2
)
756 FIXME("(%p,%p,%p): stub\n", iface
, arg1
, arg2
);
757 if (arg2
) *arg2
= NULL
;
761 static HRESULT WINAPI
IMILUnknown2Impl_unknown2(IMILUnknown2
*iface
, void *arg1
, void *arg2
)
763 FIXME("(%p,%p,%p): stub\n", iface
, arg1
, arg2
);
767 static HRESULT WINAPI
IMILUnknown2Impl_unknown3(IMILUnknown2
*iface
, void *arg1
)
769 FIXME("(%p,%p): stub\n", iface
, arg1
);
773 static const IMILUnknown2Vtbl IMILUnknown2Impl_Vtbl
=
775 IMILUnknown2Impl_QueryInterface
,
776 IMILUnknown2Impl_AddRef
,
777 IMILUnknown2Impl_Release
,
778 IMILUnknown2Impl_unknown1
,
779 IMILUnknown2Impl_unknown2
,
780 IMILUnknown2Impl_unknown3
783 HRESULT
BitmapImpl_Create(UINT uiWidth
, UINT uiHeight
, UINT stride
, UINT datasize
, void *view
,
784 UINT offset
, REFWICPixelFormatGUID pixelFormat
, WICBitmapCreateCacheOption option
,
785 IWICBitmap
**ppIBitmap
)
792 hr
= get_pixelformat_bpp(pixelFormat
, &bpp
);
793 if (FAILED(hr
)) return hr
;
795 if (!stride
) stride
= (((bpp
*uiWidth
)+31)/32)*4;
796 if (!datasize
) datasize
= stride
* uiHeight
;
798 if (datasize
< stride
* uiHeight
) return WINCODEC_ERR_INSUFFICIENTBUFFER
;
799 if (stride
< ((bpp
*uiWidth
)+7)/8) return E_INVALIDARG
;
801 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapImpl
));
802 if (!This
) return E_OUTOFMEMORY
;
804 if (view
) data
= (BYTE
*)view
+ offset
;
805 else if (!(data
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, datasize
)))
807 HeapFree(GetProcessHeap(), 0, This
);
808 return E_OUTOFMEMORY
;
811 This
->IWICBitmap_iface
.lpVtbl
= &BitmapImpl_Vtbl
;
812 This
->IMILBitmap_iface
.lpVtbl
= &IMILBitmapImpl_Vtbl
;
813 This
->IMILUnknown1_iface
.lpVtbl
= &IMILUnknown1Impl_Vtbl
;
814 This
->IMILUnknown2_iface
.lpVtbl
= &IMILUnknown2Impl_Vtbl
;
816 This
->palette
= NULL
;
817 This
->palette_set
= 0;
821 This
->offset
= offset
;
822 This
->width
= uiWidth
;
823 This
->height
= uiHeight
;
824 This
->stride
= stride
;
826 memcpy(&This
->pixelformat
, pixelFormat
, sizeof(GUID
));
827 This
->dpix
= This
->dpiy
= 0.0;
828 InitializeCriticalSection(&This
->cs
);
829 This
->cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": BitmapImpl.lock");
831 *ppIBitmap
= &This
->IWICBitmap_iface
;