2 * Copyright 2012 Vincent Povirk for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #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 IMILBitmapSource IMILBitmapSource_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 BOOL is_section
; /* TRUE if data is a section created by an application */
52 WICPixelFormatGUID pixelformat
;
57 typedef struct BitmapLockImpl
{
58 IWICBitmapLock IWICBitmapLock_iface
;
65 static inline BitmapImpl
*impl_from_IWICBitmap(IWICBitmap
*iface
)
67 return CONTAINING_RECORD(iface
, BitmapImpl
, IWICBitmap_iface
);
70 static inline BitmapImpl
*impl_from_IMILBitmapSource(IMILBitmapSource
*iface
)
72 return CONTAINING_RECORD(iface
, BitmapImpl
, IMILBitmapSource_iface
);
75 static inline BitmapImpl
*impl_from_IMILUnknown1(IMILUnknown1
*iface
)
77 return CONTAINING_RECORD(iface
, BitmapImpl
, IMILUnknown1_iface
);
80 static inline BitmapImpl
*impl_from_IMILUnknown2(IMILUnknown2
*iface
)
82 return CONTAINING_RECORD(iface
, BitmapImpl
, IMILUnknown2_iface
);
85 static inline BitmapLockImpl
*impl_from_IWICBitmapLock(IWICBitmapLock
*iface
)
87 return CONTAINING_RECORD(iface
, BitmapLockImpl
, IWICBitmapLock_iface
);
90 static BOOL
BitmapImpl_AcquireLock(BitmapImpl
*This
, int write
)
94 return 0 == InterlockedCompareExchange(&This
->lock
, -1, 0);
100 LONG prev_val
= This
->lock
;
103 if (prev_val
== InterlockedCompareExchange(&This
->lock
, prev_val
+1, prev_val
))
109 static void BitmapImpl_ReleaseLock(BitmapImpl
*This
)
113 LONG prev_val
= This
->lock
, new_val
;
117 new_val
= prev_val
- 1;
118 if (prev_val
== InterlockedCompareExchange(&This
->lock
, new_val
, prev_val
))
124 static HRESULT WINAPI
BitmapLockImpl_QueryInterface(IWICBitmapLock
*iface
, REFIID iid
,
127 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
128 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
130 if (!ppv
) return E_INVALIDARG
;
132 if (IsEqualIID(&IID_IUnknown
, iid
) ||
133 IsEqualIID(&IID_IWICBitmapLock
, iid
))
135 *ppv
= &This
->IWICBitmapLock_iface
;
139 FIXME("unknown interface %s\n", debugstr_guid(iid
));
141 return E_NOINTERFACE
;
144 IUnknown_AddRef((IUnknown
*)*ppv
);
148 static ULONG WINAPI
BitmapLockImpl_AddRef(IWICBitmapLock
*iface
)
150 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
151 ULONG ref
= InterlockedIncrement(&This
->ref
);
153 TRACE("(%p) refcount=%u\n", iface
, ref
);
158 static ULONG WINAPI
BitmapLockImpl_Release(IWICBitmapLock
*iface
)
160 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
161 ULONG ref
= InterlockedDecrement(&This
->ref
);
163 TRACE("(%p) refcount=%u\n", iface
, ref
);
167 BitmapImpl_ReleaseLock(This
->parent
);
168 IWICBitmap_Release(&This
->parent
->IWICBitmap_iface
);
169 HeapFree(GetProcessHeap(), 0, This
);
175 static HRESULT WINAPI
BitmapLockImpl_GetSize(IWICBitmapLock
*iface
,
176 UINT
*puiWidth
, UINT
*puiHeight
)
178 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
179 TRACE("(%p,%p,%p)\n", iface
, puiWidth
, puiHeight
);
181 if (!puiWidth
|| !puiHeight
)
184 *puiWidth
= This
->width
;
185 *puiHeight
= This
->height
;
190 static HRESULT WINAPI
BitmapLockImpl_GetStride(IWICBitmapLock
*iface
,
193 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
194 TRACE("(%p,%p)\n", iface
, pcbStride
);
199 *pcbStride
= This
->parent
->stride
;
204 static HRESULT WINAPI
BitmapLockImpl_GetDataPointer(IWICBitmapLock
*iface
,
205 UINT
*pcbBufferSize
, BYTE
**ppbData
)
207 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
208 TRACE("(%p,%p,%p)\n", iface
, pcbBufferSize
, ppbData
);
210 if (!pcbBufferSize
|| !ppbData
)
213 *pcbBufferSize
= This
->parent
->stride
* (This
->height
- 1) +
214 ((This
->parent
->bpp
* This
->width
) + 7)/8;
215 *ppbData
= This
->data
;
220 static HRESULT WINAPI
BitmapLockImpl_GetPixelFormat(IWICBitmapLock
*iface
,
221 WICPixelFormatGUID
*pPixelFormat
)
223 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
224 TRACE("(%p,%p)\n", iface
, pPixelFormat
);
226 return IWICBitmap_GetPixelFormat(&This
->parent
->IWICBitmap_iface
, pPixelFormat
);
229 static const IWICBitmapLockVtbl BitmapLockImpl_Vtbl
= {
230 BitmapLockImpl_QueryInterface
,
231 BitmapLockImpl_AddRef
,
232 BitmapLockImpl_Release
,
233 BitmapLockImpl_GetSize
,
234 BitmapLockImpl_GetStride
,
235 BitmapLockImpl_GetDataPointer
,
236 BitmapLockImpl_GetPixelFormat
239 static HRESULT WINAPI
BitmapImpl_QueryInterface(IWICBitmap
*iface
, REFIID iid
,
242 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
243 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
245 if (!ppv
) return E_INVALIDARG
;
247 if (IsEqualIID(&IID_IUnknown
, iid
) ||
248 IsEqualIID(&IID_IWICBitmapSource
, iid
) ||
249 IsEqualIID(&IID_IWICBitmap
, iid
))
251 *ppv
= &This
->IWICBitmap_iface
;
253 else if (IsEqualIID(&IID_IMILBitmap
, iid
) ||
254 IsEqualIID(&IID_IMILBitmapSource
, iid
))
256 *ppv
= &This
->IMILBitmapSource_iface
;
260 FIXME("unknown interface %s\n", debugstr_guid(iid
));
262 return E_NOINTERFACE
;
265 IUnknown_AddRef((IUnknown
*)*ppv
);
269 static ULONG WINAPI
BitmapImpl_AddRef(IWICBitmap
*iface
)
271 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
272 ULONG ref
= InterlockedIncrement(&This
->ref
);
274 TRACE("(%p) refcount=%u\n", iface
, ref
);
279 static ULONG WINAPI
BitmapImpl_Release(IWICBitmap
*iface
)
281 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
282 ULONG ref
= InterlockedDecrement(&This
->ref
);
284 TRACE("(%p) refcount=%u\n", iface
, ref
);
288 if (This
->palette
) IWICPalette_Release(This
->palette
);
289 This
->cs
.DebugInfo
->Spare
[0] = 0;
290 DeleteCriticalSection(&This
->cs
);
291 if (This
->is_section
)
292 UnmapViewOfFile(This
->data
);
294 HeapFree(GetProcessHeap(), 0, This
->data
);
295 HeapFree(GetProcessHeap(), 0, This
);
301 static HRESULT WINAPI
BitmapImpl_GetSize(IWICBitmap
*iface
,
302 UINT
*puiWidth
, UINT
*puiHeight
)
304 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
305 TRACE("(%p,%p,%p)\n", iface
, puiWidth
, puiHeight
);
307 if (!puiWidth
|| !puiHeight
)
310 *puiWidth
= This
->width
;
311 *puiHeight
= This
->height
;
316 static HRESULT WINAPI
BitmapImpl_GetPixelFormat(IWICBitmap
*iface
,
317 WICPixelFormatGUID
*pPixelFormat
)
319 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
320 TRACE("(%p,%p)\n", iface
, pPixelFormat
);
325 memcpy(pPixelFormat
, &This
->pixelformat
, sizeof(GUID
));
330 static HRESULT WINAPI
BitmapImpl_GetResolution(IWICBitmap
*iface
,
331 double *pDpiX
, double *pDpiY
)
333 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
334 TRACE("(%p,%p,%p)\n", iface
, pDpiX
, pDpiY
);
336 if (!pDpiX
|| !pDpiY
)
339 EnterCriticalSection(&This
->cs
);
342 LeaveCriticalSection(&This
->cs
);
347 static HRESULT WINAPI
BitmapImpl_CopyPalette(IWICBitmap
*iface
,
348 IWICPalette
*pIPalette
)
350 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
351 TRACE("(%p,%p)\n", iface
, pIPalette
);
353 if (!This
->palette_set
)
354 return WINCODEC_ERR_PALETTEUNAVAILABLE
;
356 return IWICPalette_InitializeFromPalette(pIPalette
, This
->palette
);
359 static HRESULT WINAPI
BitmapImpl_CopyPixels(IWICBitmap
*iface
,
360 const WICRect
*prc
, UINT cbStride
, UINT cbBufferSize
, BYTE
*pbBuffer
)
362 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
363 TRACE("(%p,%p,%u,%u,%p)\n", iface
, prc
, cbStride
, cbBufferSize
, pbBuffer
);
365 return copy_pixels(This
->bpp
, This
->data
, This
->width
, This
->height
,
366 This
->stride
, prc
, cbStride
, cbBufferSize
, pbBuffer
);
369 static HRESULT WINAPI
BitmapImpl_Lock(IWICBitmap
*iface
, const WICRect
*prcLock
,
370 DWORD flags
, IWICBitmapLock
**ppILock
)
372 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
373 BitmapLockImpl
*result
;
376 TRACE("(%p,%p,%x,%p)\n", iface
, prcLock
, flags
, ppILock
);
378 if (!(flags
& (WICBitmapLockRead
|WICBitmapLockWrite
)) || !ppILock
)
384 rc
.Width
= This
->width
;
385 rc
.Height
= This
->height
;
388 else if (prcLock
->X
>= This
->width
|| prcLock
->Y
>= This
->height
||
389 prcLock
->X
+ prcLock
->Width
> This
->width
||
390 prcLock
->Y
+ prcLock
->Height
> This
->height
||
391 prcLock
->Width
<= 0 || prcLock
->Height
<= 0)
393 else if (((prcLock
->X
* This
->bpp
) % 8) != 0)
395 FIXME("Cannot lock at an X coordinate not at a full byte\n");
399 result
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapLockImpl
));
401 return E_OUTOFMEMORY
;
403 if (!BitmapImpl_AcquireLock(This
, flags
& WICBitmapLockWrite
))
405 HeapFree(GetProcessHeap(), 0, result
);
406 return WINCODEC_ERR_ALREADYLOCKED
;
409 result
->IWICBitmapLock_iface
.lpVtbl
= &BitmapLockImpl_Vtbl
;
411 result
->parent
= This
;
412 result
->width
= prcLock
->Width
;
413 result
->height
= prcLock
->Height
;
414 result
->data
= This
->data
+ This
->stride
* prcLock
->Y
+
415 (This
->bpp
* prcLock
->X
)/8;
417 IWICBitmap_AddRef(&This
->IWICBitmap_iface
);
418 *ppILock
= &result
->IWICBitmapLock_iface
;
423 static HRESULT WINAPI
BitmapImpl_SetPalette(IWICBitmap
*iface
, IWICPalette
*pIPalette
)
425 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
428 TRACE("(%p,%p)\n", iface
, pIPalette
);
432 IWICPalette
*new_palette
;
433 hr
= PaletteImpl_Create(&new_palette
);
435 if (FAILED(hr
)) return hr
;
437 if (InterlockedCompareExchangePointer((void**)&This
->palette
, new_palette
, NULL
))
439 /* someone beat us to it */
440 IWICPalette_Release(new_palette
);
444 hr
= IWICPalette_InitializeFromPalette(This
->palette
, pIPalette
);
447 This
->palette_set
= 1;
452 static HRESULT WINAPI
BitmapImpl_SetResolution(IWICBitmap
*iface
,
453 double dpiX
, double dpiY
)
455 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
456 TRACE("(%p,%f,%f)\n", iface
, dpiX
, dpiY
);
458 EnterCriticalSection(&This
->cs
);
461 LeaveCriticalSection(&This
->cs
);
466 static const IWICBitmapVtbl BitmapImpl_Vtbl
= {
467 BitmapImpl_QueryInterface
,
471 BitmapImpl_GetPixelFormat
,
472 BitmapImpl_GetResolution
,
473 BitmapImpl_CopyPalette
,
474 BitmapImpl_CopyPixels
,
476 BitmapImpl_SetPalette
,
477 BitmapImpl_SetResolution
480 static HRESULT WINAPI
IMILBitmapImpl_QueryInterface(IMILBitmapSource
*iface
, REFIID iid
,
483 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
484 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
486 if (!ppv
) return E_INVALIDARG
;
488 if (IsEqualIID(&IID_IUnknown
, iid
) ||
489 IsEqualIID(&IID_IMILBitmap
, iid
) ||
490 IsEqualIID(&IID_IMILBitmapSource
, iid
))
492 IUnknown_AddRef(&This
->IMILBitmapSource_iface
);
493 *ppv
= &This
->IMILBitmapSource_iface
;
496 else if (IsEqualIID(&IID_IWICBitmap
, iid
) ||
497 IsEqualIID(&IID_IWICBitmapSource
, iid
))
499 IUnknown_AddRef(&This
->IWICBitmap_iface
);
500 *ppv
= &This
->IWICBitmap_iface
;
504 FIXME("unknown interface %s\n", debugstr_guid(iid
));
506 return E_NOINTERFACE
;
509 static ULONG WINAPI
IMILBitmapImpl_AddRef(IMILBitmapSource
*iface
)
511 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
512 return IWICBitmap_AddRef(&This
->IWICBitmap_iface
);
515 static ULONG WINAPI
IMILBitmapImpl_Release(IMILBitmapSource
*iface
)
517 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
518 return IWICBitmap_Release(&This
->IWICBitmap_iface
);
521 static HRESULT WINAPI
IMILBitmapImpl_GetSize(IMILBitmapSource
*iface
,
522 UINT
*width
, UINT
*height
)
524 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
525 TRACE("(%p,%p,%p)\n", iface
, width
, height
);
526 return IWICBitmap_GetSize(&This
->IWICBitmap_iface
, width
, height
);
531 const GUID
*WIC_format
;
535 { &GUID_WICPixelFormatDontCare
, 0 },
536 { &GUID_WICPixelFormat1bppIndexed
, 1 },
537 { &GUID_WICPixelFormat2bppIndexed
, 2 },
538 { &GUID_WICPixelFormat4bppIndexed
, 3 },
539 { &GUID_WICPixelFormat8bppIndexed
, 4 },
540 { &GUID_WICPixelFormatBlackWhite
, 5 },
541 { &GUID_WICPixelFormat2bppGray
, 6 },
542 { &GUID_WICPixelFormat4bppGray
, 7 },
543 { &GUID_WICPixelFormat8bppGray
, 8 },
544 { &GUID_WICPixelFormat16bppBGR555
, 9 },
545 { &GUID_WICPixelFormat16bppBGR565
, 0x0a },
546 { &GUID_WICPixelFormat16bppGray
, 0x0b },
547 { &GUID_WICPixelFormat24bppBGR
, 0x0c },
548 { &GUID_WICPixelFormat24bppRGB
, 0x0d },
549 { &GUID_WICPixelFormat32bppBGR
, 0x0e },
550 { &GUID_WICPixelFormat32bppBGRA
, 0x0f },
551 { &GUID_WICPixelFormat32bppPBGRA
, 0x10 },
552 { &GUID_WICPixelFormat48bppRGB
, 0x15 },
553 { &GUID_WICPixelFormat64bppRGBA
, 0x16 },
554 { &GUID_WICPixelFormat64bppPRGBA
, 0x17 },
555 { &GUID_WICPixelFormat32bppCMYK
, 0x1c }
558 static HRESULT WINAPI
IMILBitmapImpl_GetPixelFormat(IMILBitmapSource
*iface
,
561 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
564 TRACE("(%p,%p)\n", iface
, format
);
566 if (!format
) return E_INVALIDARG
;
570 for (i
= 0; i
< sizeof(pixel_fmt_map
)/sizeof(pixel_fmt_map
[0]); i
++)
572 if (IsEqualGUID(pixel_fmt_map
[i
].WIC_format
, &This
->pixelformat
))
574 *format
= pixel_fmt_map
[i
].enum_format
;
579 TRACE("=> %u\n", *format
);
583 static HRESULT WINAPI
IMILBitmapImpl_GetResolution(IMILBitmapSource
*iface
,
584 double *dpix
, double *dpiy
)
586 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
587 TRACE("(%p,%p,%p)\n", iface
, dpix
, dpiy
);
588 return IWICBitmap_GetResolution(&This
->IWICBitmap_iface
, dpix
, dpiy
);
591 static HRESULT WINAPI
IMILBitmapImpl_CopyPalette(IMILBitmapSource
*iface
,
592 IWICPalette
*palette
)
594 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
595 TRACE("(%p,%p)\n", iface
, palette
);
596 return IWICBitmap_CopyPalette(&This
->IWICBitmap_iface
, palette
);
599 static HRESULT WINAPI
IMILBitmapImpl_CopyPixels(IMILBitmapSource
*iface
,
600 const WICRect
*rc
, UINT stride
, UINT size
, BYTE
*buffer
)
602 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
603 TRACE("(%p,%p,%u,%u,%p)\n", iface
, rc
, stride
, size
, buffer
);
604 return IWICBitmap_CopyPixels(&This
->IWICBitmap_iface
, rc
, stride
, size
, buffer
);
607 static HRESULT WINAPI
IMILBitmapImpl_unknown1(IMILBitmapSource
*iface
, void **ppv
)
609 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
611 TRACE("(%p,%p)\n", iface
, ppv
);
613 if (!ppv
) return E_INVALIDARG
;
615 /* reference count is not incremented here */
616 *ppv
= &This
->IMILUnknown1_iface
;
621 static HRESULT WINAPI
IMILBitmapImpl_Lock(IMILBitmapSource
*iface
, const WICRect
*rc
, DWORD flags
, IWICBitmapLock
**lock
)
623 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
624 TRACE("(%p,%p,%08x,%p)\n", iface
, rc
, flags
, lock
);
625 return IWICBitmap_Lock(&This
->IWICBitmap_iface
, rc
, flags
, lock
);
628 static HRESULT WINAPI
IMILBitmapImpl_Unlock(IMILBitmapSource
*iface
, IWICBitmapLock
*lock
)
630 TRACE("(%p,%p)\n", iface
, lock
);
631 IWICBitmapLock_Release(lock
);
635 static HRESULT WINAPI
IMILBitmapImpl_SetPalette(IMILBitmapSource
*iface
, IWICPalette
*palette
)
637 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
638 TRACE("(%p,%p)\n", iface
, palette
);
639 return IWICBitmap_SetPalette(&This
->IWICBitmap_iface
, palette
);
642 static HRESULT WINAPI
IMILBitmapImpl_SetResolution(IMILBitmapSource
*iface
, double dpix
, double dpiy
)
644 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
645 TRACE("(%p,%f,%f)\n", iface
, dpix
, dpiy
);
646 return IWICBitmap_SetResolution(&This
->IWICBitmap_iface
, dpix
, dpiy
);
649 static HRESULT WINAPI
IMILBitmapImpl_AddDirtyRect(IMILBitmapSource
*iface
, const WICRect
*rc
)
651 FIXME("(%p,%p): stub\n", iface
, rc
);
655 static const IMILBitmapSourceVtbl IMILBitmapImpl_Vtbl
=
657 IMILBitmapImpl_QueryInterface
,
658 IMILBitmapImpl_AddRef
,
659 IMILBitmapImpl_Release
,
660 IMILBitmapImpl_GetSize
,
661 IMILBitmapImpl_GetPixelFormat
,
662 IMILBitmapImpl_GetResolution
,
663 IMILBitmapImpl_CopyPalette
,
664 IMILBitmapImpl_CopyPixels
,
665 IMILBitmapImpl_unknown1
,
667 IMILBitmapImpl_Unlock
,
668 IMILBitmapImpl_SetPalette
,
669 IMILBitmapImpl_SetResolution
,
670 IMILBitmapImpl_AddDirtyRect
673 static HRESULT WINAPI
IMILUnknown1Impl_QueryInterface(IMILUnknown1
*iface
, REFIID iid
,
676 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_guid(iid
), ppv
);
678 return E_NOINTERFACE
;
681 static ULONG WINAPI
IMILUnknown1Impl_AddRef(IMILUnknown1
*iface
)
683 BitmapImpl
*This
= impl_from_IMILUnknown1(iface
);
684 return IWICBitmap_AddRef(&This
->IWICBitmap_iface
);
687 static ULONG WINAPI
IMILUnknown1Impl_Release(IMILUnknown1
*iface
)
689 BitmapImpl
*This
= impl_from_IMILUnknown1(iface
);
690 return IWICBitmap_Release(&This
->IWICBitmap_iface
);
693 DECLSPEC_HIDDEN
void WINAPI
IMILUnknown1Impl_unknown1(IMILUnknown1
*iface
, void *arg
)
695 FIXME("(%p,%p): stub\n", iface
, arg
);
698 static HRESULT WINAPI
IMILUnknown1Impl_unknown2(IMILUnknown1
*iface
, void *arg1
, void *arg2
)
700 FIXME("(%p,%p,%p): stub\n", iface
, arg1
, arg2
);
704 DECLSPEC_HIDDEN HRESULT WINAPI
IMILUnknown1Impl_unknown3(IMILUnknown1
*iface
, void *arg
)
706 FIXME("(%p,%p): stub\n", iface
, arg
);
710 static HRESULT WINAPI
IMILUnknown1Impl_unknown4(IMILUnknown1
*iface
, void *arg
)
712 FIXME("(%p,%p): stub\n", iface
, arg
);
716 static HRESULT WINAPI
IMILUnknown1Impl_unknown5(IMILUnknown1
*iface
, void *arg
)
718 FIXME("(%p,%p): stub\n", iface
, arg
);
722 static HRESULT WINAPI
IMILUnknown1Impl_unknown6(IMILUnknown1
*iface
, DWORD64 arg
)
724 FIXME("(%p,%s): stub\n", iface
, wine_dbgstr_longlong(arg
));
728 static HRESULT WINAPI
IMILUnknown1Impl_unknown7(IMILUnknown1
*iface
, void *arg
)
730 FIXME("(%p,%p): stub\n", iface
, arg
);
734 DECLSPEC_HIDDEN HRESULT WINAPI
IMILUnknown1Impl_unknown8(IMILUnknown1
*iface
)
736 FIXME("(%p): stub\n", iface
);
740 DEFINE_THISCALL_WRAPPER(IMILUnknown1Impl_unknown1
, 8)
741 DEFINE_THISCALL_WRAPPER(IMILUnknown1Impl_unknown3
, 8)
742 DEFINE_THISCALL_WRAPPER(IMILUnknown1Impl_unknown8
, 4)
744 static const IMILUnknown1Vtbl IMILUnknown1Impl_Vtbl
=
746 IMILUnknown1Impl_QueryInterface
,
747 IMILUnknown1Impl_AddRef
,
748 IMILUnknown1Impl_Release
,
749 THISCALL(IMILUnknown1Impl_unknown1
),
750 IMILUnknown1Impl_unknown2
,
751 THISCALL(IMILUnknown1Impl_unknown3
),
752 IMILUnknown1Impl_unknown4
,
753 IMILUnknown1Impl_unknown5
,
754 IMILUnknown1Impl_unknown6
,
755 IMILUnknown1Impl_unknown7
,
756 THISCALL(IMILUnknown1Impl_unknown8
)
759 static HRESULT WINAPI
IMILUnknown2Impl_QueryInterface(IMILUnknown2
*iface
, REFIID iid
,
762 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_guid(iid
), ppv
);
764 return E_NOINTERFACE
;
767 static ULONG WINAPI
IMILUnknown2Impl_AddRef(IMILUnknown2
*iface
)
769 FIXME("(%p): stub\n", iface
);
773 static ULONG WINAPI
IMILUnknown2Impl_Release(IMILUnknown2
*iface
)
775 FIXME("(%p): stub\n", iface
);
779 static HRESULT WINAPI
IMILUnknown2Impl_unknown1(IMILUnknown2
*iface
, void *arg1
, void **arg2
)
781 FIXME("(%p,%p,%p): stub\n", iface
, arg1
, arg2
);
782 if (arg2
) *arg2
= NULL
;
786 static HRESULT WINAPI
IMILUnknown2Impl_unknown2(IMILUnknown2
*iface
, void *arg1
, void *arg2
)
788 FIXME("(%p,%p,%p): stub\n", iface
, arg1
, arg2
);
792 static HRESULT WINAPI
IMILUnknown2Impl_unknown3(IMILUnknown2
*iface
, void *arg1
)
794 FIXME("(%p,%p): stub\n", iface
, arg1
);
798 static const IMILUnknown2Vtbl IMILUnknown2Impl_Vtbl
=
800 IMILUnknown2Impl_QueryInterface
,
801 IMILUnknown2Impl_AddRef
,
802 IMILUnknown2Impl_Release
,
803 IMILUnknown2Impl_unknown1
,
804 IMILUnknown2Impl_unknown2
,
805 IMILUnknown2Impl_unknown3
808 HRESULT
BitmapImpl_Create(UINT uiWidth
, UINT uiHeight
,
809 UINT stride
, UINT datasize
, BYTE
*data
,
810 REFWICPixelFormatGUID pixelFormat
, WICBitmapCreateCacheOption option
,
811 IWICBitmap
**ppIBitmap
)
817 hr
= get_pixelformat_bpp(pixelFormat
, &bpp
);
818 if (FAILED(hr
)) return hr
;
820 if (!stride
) stride
= (((bpp
*uiWidth
)+31)/32)*4;
821 if (!datasize
) datasize
= stride
* uiHeight
;
823 if (datasize
< stride
* uiHeight
) return WINCODEC_ERR_INSUFFICIENTBUFFER
;
824 if (stride
< ((bpp
*uiWidth
)+7)/8) return E_INVALIDARG
;
826 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapImpl
));
827 if (!This
) return E_OUTOFMEMORY
;
831 data
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, datasize
);
834 HeapFree(GetProcessHeap(), 0, This
);
835 return E_OUTOFMEMORY
;
837 This
->is_section
= FALSE
;
840 This
->is_section
= TRUE
;
842 This
->IWICBitmap_iface
.lpVtbl
= &BitmapImpl_Vtbl
;
843 This
->IMILBitmapSource_iface
.lpVtbl
= &IMILBitmapImpl_Vtbl
;
844 This
->IMILUnknown1_iface
.lpVtbl
= &IMILUnknown1Impl_Vtbl
;
845 This
->IMILUnknown2_iface
.lpVtbl
= &IMILUnknown2Impl_Vtbl
;
847 This
->palette
= NULL
;
848 This
->palette_set
= 0;
851 This
->width
= uiWidth
;
852 This
->height
= uiHeight
;
853 This
->stride
= stride
;
855 memcpy(&This
->pixelformat
, pixelFormat
, sizeof(GUID
));
856 This
->dpix
= This
->dpiy
= 0.0;
857 InitializeCriticalSection(&This
->cs
);
858 This
->cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": BitmapImpl.lock");
860 *ppIBitmap
= &This
->IWICBitmap_iface
;