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 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_IMILBitmapSource(IMILBitmapSource
*iface
)
73 return CONTAINING_RECORD(iface
, BitmapImpl
, IMILBitmapSource_iface
);
76 static inline BitmapImpl
*impl_from_IMILUnknown1(IMILUnknown1
*iface
)
78 return CONTAINING_RECORD(iface
, BitmapImpl
, IMILUnknown1_iface
);
81 static inline BitmapImpl
*impl_from_IMILUnknown2(IMILUnknown2
*iface
)
83 return CONTAINING_RECORD(iface
, BitmapImpl
, IMILUnknown2_iface
);
86 static inline BitmapLockImpl
*impl_from_IWICBitmapLock(IWICBitmapLock
*iface
)
88 return CONTAINING_RECORD(iface
, BitmapLockImpl
, IWICBitmapLock_iface
);
91 static BOOL
BitmapImpl_AcquireLock(BitmapImpl
*This
, int write
)
95 return 0 == InterlockedCompareExchange(&This
->lock
, -1, 0);
101 LONG prev_val
= This
->lock
;
104 if (prev_val
== InterlockedCompareExchange(&This
->lock
, prev_val
+1, prev_val
))
110 static void BitmapImpl_ReleaseLock(BitmapImpl
*This
)
114 LONG prev_val
= This
->lock
, new_val
;
118 new_val
= prev_val
- 1;
119 if (prev_val
== InterlockedCompareExchange(&This
->lock
, new_val
, prev_val
))
125 static HRESULT WINAPI
BitmapLockImpl_QueryInterface(IWICBitmapLock
*iface
, REFIID iid
,
128 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
129 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
131 if (!ppv
) return E_INVALIDARG
;
133 if (IsEqualIID(&IID_IUnknown
, iid
) ||
134 IsEqualIID(&IID_IWICBitmapLock
, iid
))
136 *ppv
= &This
->IWICBitmapLock_iface
;
140 FIXME("unknown interface %s\n", debugstr_guid(iid
));
142 return E_NOINTERFACE
;
145 IUnknown_AddRef((IUnknown
*)*ppv
);
149 static ULONG WINAPI
BitmapLockImpl_AddRef(IWICBitmapLock
*iface
)
151 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
152 ULONG ref
= InterlockedIncrement(&This
->ref
);
154 TRACE("(%p) refcount=%u\n", iface
, ref
);
159 static ULONG WINAPI
BitmapLockImpl_Release(IWICBitmapLock
*iface
)
161 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
162 ULONG ref
= InterlockedDecrement(&This
->ref
);
164 TRACE("(%p) refcount=%u\n", iface
, ref
);
168 BitmapImpl_ReleaseLock(This
->parent
);
169 IWICBitmap_Release(&This
->parent
->IWICBitmap_iface
);
170 HeapFree(GetProcessHeap(), 0, This
);
176 static HRESULT WINAPI
BitmapLockImpl_GetSize(IWICBitmapLock
*iface
,
177 UINT
*puiWidth
, UINT
*puiHeight
)
179 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
180 TRACE("(%p,%p,%p)\n", iface
, puiWidth
, puiHeight
);
182 if (!puiWidth
|| !puiHeight
)
185 *puiWidth
= This
->width
;
186 *puiHeight
= This
->height
;
191 static HRESULT WINAPI
BitmapLockImpl_GetStride(IWICBitmapLock
*iface
,
194 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
195 TRACE("(%p,%p)\n", iface
, pcbStride
);
200 *pcbStride
= This
->parent
->stride
;
205 static HRESULT WINAPI
BitmapLockImpl_GetDataPointer(IWICBitmapLock
*iface
,
206 UINT
*pcbBufferSize
, BYTE
**ppbData
)
208 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
209 TRACE("(%p,%p,%p)\n", iface
, pcbBufferSize
, ppbData
);
211 if (!pcbBufferSize
|| !ppbData
)
214 *pcbBufferSize
= This
->parent
->stride
* (This
->height
- 1) +
215 ((This
->parent
->bpp
* This
->width
) + 7)/8;
216 *ppbData
= This
->data
;
221 static HRESULT WINAPI
BitmapLockImpl_GetPixelFormat(IWICBitmapLock
*iface
,
222 WICPixelFormatGUID
*pPixelFormat
)
224 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
225 TRACE("(%p,%p)\n", iface
, pPixelFormat
);
227 return IWICBitmap_GetPixelFormat(&This
->parent
->IWICBitmap_iface
, pPixelFormat
);
230 static const IWICBitmapLockVtbl BitmapLockImpl_Vtbl
= {
231 BitmapLockImpl_QueryInterface
,
232 BitmapLockImpl_AddRef
,
233 BitmapLockImpl_Release
,
234 BitmapLockImpl_GetSize
,
235 BitmapLockImpl_GetStride
,
236 BitmapLockImpl_GetDataPointer
,
237 BitmapLockImpl_GetPixelFormat
240 static HRESULT WINAPI
BitmapImpl_QueryInterface(IWICBitmap
*iface
, REFIID iid
,
243 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
244 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
246 if (!ppv
) return E_INVALIDARG
;
248 if (IsEqualIID(&IID_IUnknown
, iid
) ||
249 IsEqualIID(&IID_IWICBitmapSource
, iid
) ||
250 IsEqualIID(&IID_IWICBitmap
, iid
))
252 *ppv
= &This
->IWICBitmap_iface
;
254 else if (IsEqualIID(&IID_IMILBitmap
, iid
) ||
255 IsEqualIID(&IID_IMILBitmapSource
, iid
))
257 *ppv
= &This
->IMILBitmapSource_iface
;
261 FIXME("unknown interface %s\n", debugstr_guid(iid
));
263 return E_NOINTERFACE
;
266 IUnknown_AddRef((IUnknown
*)*ppv
);
270 static ULONG WINAPI
BitmapImpl_AddRef(IWICBitmap
*iface
)
272 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
273 ULONG ref
= InterlockedIncrement(&This
->ref
);
275 TRACE("(%p) refcount=%u\n", iface
, ref
);
280 static ULONG WINAPI
BitmapImpl_Release(IWICBitmap
*iface
)
282 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
283 ULONG ref
= InterlockedDecrement(&This
->ref
);
285 TRACE("(%p) refcount=%u\n", iface
, ref
);
289 if (This
->palette
) IWICPalette_Release(This
->palette
);
290 This
->cs
.DebugInfo
->Spare
[0] = 0;
291 DeleteCriticalSection(&This
->cs
);
293 UnmapViewOfFile(This
->view
);
295 HeapFree(GetProcessHeap(), 0, This
->data
);
296 HeapFree(GetProcessHeap(), 0, This
);
302 static HRESULT WINAPI
BitmapImpl_GetSize(IWICBitmap
*iface
,
303 UINT
*puiWidth
, UINT
*puiHeight
)
305 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
306 TRACE("(%p,%p,%p)\n", iface
, puiWidth
, puiHeight
);
308 if (!puiWidth
|| !puiHeight
)
311 *puiWidth
= This
->width
;
312 *puiHeight
= This
->height
;
317 static HRESULT WINAPI
BitmapImpl_GetPixelFormat(IWICBitmap
*iface
,
318 WICPixelFormatGUID
*pPixelFormat
)
320 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
321 TRACE("(%p,%p)\n", iface
, pPixelFormat
);
326 memcpy(pPixelFormat
, &This
->pixelformat
, sizeof(GUID
));
331 static HRESULT WINAPI
BitmapImpl_GetResolution(IWICBitmap
*iface
,
332 double *pDpiX
, double *pDpiY
)
334 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
335 TRACE("(%p,%p,%p)\n", iface
, pDpiX
, pDpiY
);
337 if (!pDpiX
|| !pDpiY
)
340 EnterCriticalSection(&This
->cs
);
343 LeaveCriticalSection(&This
->cs
);
348 static HRESULT WINAPI
BitmapImpl_CopyPalette(IWICBitmap
*iface
,
349 IWICPalette
*pIPalette
)
351 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
352 TRACE("(%p,%p)\n", iface
, pIPalette
);
354 if (!This
->palette_set
)
355 return WINCODEC_ERR_PALETTEUNAVAILABLE
;
357 return IWICPalette_InitializeFromPalette(pIPalette
, This
->palette
);
360 static HRESULT WINAPI
BitmapImpl_CopyPixels(IWICBitmap
*iface
,
361 const WICRect
*prc
, UINT cbStride
, UINT cbBufferSize
, BYTE
*pbBuffer
)
363 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
364 TRACE("(%p,%s,%u,%u,%p)\n", iface
, debug_wic_rect(prc
), cbStride
, cbBufferSize
, pbBuffer
);
366 return copy_pixels(This
->bpp
, This
->data
, This
->width
, This
->height
,
367 This
->stride
, prc
, cbStride
, cbBufferSize
, pbBuffer
);
370 static HRESULT WINAPI
BitmapImpl_Lock(IWICBitmap
*iface
, const WICRect
*prcLock
,
371 DWORD flags
, IWICBitmapLock
**ppILock
)
373 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
374 BitmapLockImpl
*result
;
377 TRACE("(%p,%s,%x,%p)\n", iface
, debug_wic_rect(prcLock
), flags
, ppILock
);
379 if (!(flags
& (WICBitmapLockRead
|WICBitmapLockWrite
)) || !ppILock
)
385 rc
.Width
= This
->width
;
386 rc
.Height
= This
->height
;
389 else if (prcLock
->X
>= This
->width
|| prcLock
->Y
>= This
->height
||
390 prcLock
->X
+ prcLock
->Width
> This
->width
||
391 prcLock
->Y
+ prcLock
->Height
> This
->height
||
392 prcLock
->Width
<= 0 || prcLock
->Height
<= 0)
394 else if (((prcLock
->X
* This
->bpp
) % 8) != 0)
396 FIXME("Cannot lock at an X coordinate not at a full byte\n");
400 result
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapLockImpl
));
402 return E_OUTOFMEMORY
;
404 if (!BitmapImpl_AcquireLock(This
, flags
& WICBitmapLockWrite
))
406 HeapFree(GetProcessHeap(), 0, result
);
407 return WINCODEC_ERR_ALREADYLOCKED
;
410 result
->IWICBitmapLock_iface
.lpVtbl
= &BitmapLockImpl_Vtbl
;
412 result
->parent
= This
;
413 result
->width
= prcLock
->Width
;
414 result
->height
= prcLock
->Height
;
415 result
->data
= This
->data
+ This
->stride
* prcLock
->Y
+
416 (This
->bpp
* prcLock
->X
)/8;
418 IWICBitmap_AddRef(&This
->IWICBitmap_iface
);
419 *ppILock
= &result
->IWICBitmapLock_iface
;
424 static HRESULT WINAPI
BitmapImpl_SetPalette(IWICBitmap
*iface
, IWICPalette
*pIPalette
)
426 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
429 TRACE("(%p,%p)\n", iface
, pIPalette
);
433 IWICPalette
*new_palette
;
434 hr
= PaletteImpl_Create(&new_palette
);
436 if (FAILED(hr
)) return hr
;
438 if (InterlockedCompareExchangePointer((void**)&This
->palette
, new_palette
, NULL
))
440 /* someone beat us to it */
441 IWICPalette_Release(new_palette
);
445 hr
= IWICPalette_InitializeFromPalette(This
->palette
, pIPalette
);
448 This
->palette_set
= 1;
453 static HRESULT WINAPI
BitmapImpl_SetResolution(IWICBitmap
*iface
,
454 double dpiX
, double dpiY
)
456 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
457 TRACE("(%p,%f,%f)\n", iface
, dpiX
, dpiY
);
459 EnterCriticalSection(&This
->cs
);
462 LeaveCriticalSection(&This
->cs
);
467 static const IWICBitmapVtbl BitmapImpl_Vtbl
= {
468 BitmapImpl_QueryInterface
,
472 BitmapImpl_GetPixelFormat
,
473 BitmapImpl_GetResolution
,
474 BitmapImpl_CopyPalette
,
475 BitmapImpl_CopyPixels
,
477 BitmapImpl_SetPalette
,
478 BitmapImpl_SetResolution
481 static HRESULT WINAPI
IMILBitmapImpl_QueryInterface(IMILBitmapSource
*iface
, REFIID iid
,
484 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
485 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
487 if (!ppv
) return E_INVALIDARG
;
489 if (IsEqualIID(&IID_IUnknown
, iid
) ||
490 IsEqualIID(&IID_IMILBitmap
, iid
) ||
491 IsEqualIID(&IID_IMILBitmapSource
, iid
))
493 IUnknown_AddRef(&This
->IMILBitmapSource_iface
);
494 *ppv
= &This
->IMILBitmapSource_iface
;
497 else if (IsEqualIID(&IID_IWICBitmap
, iid
) ||
498 IsEqualIID(&IID_IWICBitmapSource
, iid
))
500 IUnknown_AddRef(&This
->IWICBitmap_iface
);
501 *ppv
= &This
->IWICBitmap_iface
;
505 FIXME("unknown interface %s\n", debugstr_guid(iid
));
507 return E_NOINTERFACE
;
510 static ULONG WINAPI
IMILBitmapImpl_AddRef(IMILBitmapSource
*iface
)
512 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
513 return IWICBitmap_AddRef(&This
->IWICBitmap_iface
);
516 static ULONG WINAPI
IMILBitmapImpl_Release(IMILBitmapSource
*iface
)
518 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
519 return IWICBitmap_Release(&This
->IWICBitmap_iface
);
522 static HRESULT WINAPI
IMILBitmapImpl_GetSize(IMILBitmapSource
*iface
,
523 UINT
*width
, UINT
*height
)
525 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
526 TRACE("(%p,%p,%p)\n", iface
, width
, height
);
527 return IWICBitmap_GetSize(&This
->IWICBitmap_iface
, width
, height
);
532 const GUID
*WIC_format
;
536 { &GUID_WICPixelFormatDontCare
, 0 },
537 { &GUID_WICPixelFormat1bppIndexed
, 1 },
538 { &GUID_WICPixelFormat2bppIndexed
, 2 },
539 { &GUID_WICPixelFormat4bppIndexed
, 3 },
540 { &GUID_WICPixelFormat8bppIndexed
, 4 },
541 { &GUID_WICPixelFormatBlackWhite
, 5 },
542 { &GUID_WICPixelFormat2bppGray
, 6 },
543 { &GUID_WICPixelFormat4bppGray
, 7 },
544 { &GUID_WICPixelFormat8bppGray
, 8 },
545 { &GUID_WICPixelFormat16bppBGR555
, 9 },
546 { &GUID_WICPixelFormat16bppBGR565
, 0x0a },
547 { &GUID_WICPixelFormat16bppGray
, 0x0b },
548 { &GUID_WICPixelFormat24bppBGR
, 0x0c },
549 { &GUID_WICPixelFormat24bppRGB
, 0x0d },
550 { &GUID_WICPixelFormat32bppBGR
, 0x0e },
551 { &GUID_WICPixelFormat32bppBGRA
, 0x0f },
552 { &GUID_WICPixelFormat32bppPBGRA
, 0x10 },
553 { &GUID_WICPixelFormat48bppRGB
, 0x15 },
554 { &GUID_WICPixelFormat64bppRGBA
, 0x16 },
555 { &GUID_WICPixelFormat64bppPRGBA
, 0x17 },
556 { &GUID_WICPixelFormat32bppCMYK
, 0x1c }
559 static HRESULT WINAPI
IMILBitmapImpl_GetPixelFormat(IMILBitmapSource
*iface
,
562 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
565 TRACE("(%p,%p)\n", iface
, format
);
567 if (!format
) return E_INVALIDARG
;
571 for (i
= 0; i
< ARRAY_SIZE(pixel_fmt_map
); i
++)
573 if (IsEqualGUID(pixel_fmt_map
[i
].WIC_format
, &This
->pixelformat
))
575 *format
= pixel_fmt_map
[i
].enum_format
;
580 TRACE("=> %u\n", *format
);
584 static HRESULT WINAPI
IMILBitmapImpl_GetResolution(IMILBitmapSource
*iface
,
585 double *dpix
, double *dpiy
)
587 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
588 TRACE("(%p,%p,%p)\n", iface
, dpix
, dpiy
);
589 return IWICBitmap_GetResolution(&This
->IWICBitmap_iface
, dpix
, dpiy
);
592 static HRESULT WINAPI
IMILBitmapImpl_CopyPalette(IMILBitmapSource
*iface
,
593 IWICPalette
*palette
)
595 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
596 TRACE("(%p,%p)\n", iface
, palette
);
597 return IWICBitmap_CopyPalette(&This
->IWICBitmap_iface
, palette
);
600 static HRESULT WINAPI
IMILBitmapImpl_CopyPixels(IMILBitmapSource
*iface
,
601 const WICRect
*rc
, UINT stride
, UINT size
, BYTE
*buffer
)
603 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
604 TRACE("(%p,%p,%u,%u,%p)\n", iface
, rc
, stride
, size
, buffer
);
605 return IWICBitmap_CopyPixels(&This
->IWICBitmap_iface
, rc
, stride
, size
, buffer
);
608 static HRESULT WINAPI
IMILBitmapImpl_unknown1(IMILBitmapSource
*iface
, void **ppv
)
610 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
612 TRACE("(%p,%p)\n", iface
, ppv
);
614 if (!ppv
) return E_INVALIDARG
;
616 /* reference count is not incremented here */
617 *ppv
= &This
->IMILUnknown1_iface
;
622 static HRESULT WINAPI
IMILBitmapImpl_Lock(IMILBitmapSource
*iface
, const WICRect
*rc
, DWORD flags
, IWICBitmapLock
**lock
)
624 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
625 TRACE("(%p,%p,%08x,%p)\n", iface
, rc
, flags
, lock
);
626 return IWICBitmap_Lock(&This
->IWICBitmap_iface
, rc
, flags
, lock
);
629 static HRESULT WINAPI
IMILBitmapImpl_Unlock(IMILBitmapSource
*iface
, IWICBitmapLock
*lock
)
631 TRACE("(%p,%p)\n", iface
, lock
);
632 IWICBitmapLock_Release(lock
);
636 static HRESULT WINAPI
IMILBitmapImpl_SetPalette(IMILBitmapSource
*iface
, IWICPalette
*palette
)
638 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
639 TRACE("(%p,%p)\n", iface
, palette
);
640 return IWICBitmap_SetPalette(&This
->IWICBitmap_iface
, palette
);
643 static HRESULT WINAPI
IMILBitmapImpl_SetResolution(IMILBitmapSource
*iface
, double dpix
, double dpiy
)
645 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
646 TRACE("(%p,%f,%f)\n", iface
, dpix
, dpiy
);
647 return IWICBitmap_SetResolution(&This
->IWICBitmap_iface
, dpix
, dpiy
);
650 static HRESULT WINAPI
IMILBitmapImpl_AddDirtyRect(IMILBitmapSource
*iface
, const WICRect
*rc
)
652 FIXME("(%p,%p): stub\n", iface
, rc
);
656 static const IMILBitmapSourceVtbl IMILBitmapImpl_Vtbl
=
658 IMILBitmapImpl_QueryInterface
,
659 IMILBitmapImpl_AddRef
,
660 IMILBitmapImpl_Release
,
661 IMILBitmapImpl_GetSize
,
662 IMILBitmapImpl_GetPixelFormat
,
663 IMILBitmapImpl_GetResolution
,
664 IMILBitmapImpl_CopyPalette
,
665 IMILBitmapImpl_CopyPixels
,
666 IMILBitmapImpl_unknown1
,
668 IMILBitmapImpl_Unlock
,
669 IMILBitmapImpl_SetPalette
,
670 IMILBitmapImpl_SetResolution
,
671 IMILBitmapImpl_AddDirtyRect
674 static HRESULT WINAPI
IMILUnknown1Impl_QueryInterface(IMILUnknown1
*iface
, REFIID iid
,
677 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_guid(iid
), ppv
);
679 return E_NOINTERFACE
;
682 static ULONG WINAPI
IMILUnknown1Impl_AddRef(IMILUnknown1
*iface
)
684 BitmapImpl
*This
= impl_from_IMILUnknown1(iface
);
685 return IWICBitmap_AddRef(&This
->IWICBitmap_iface
);
688 static ULONG WINAPI
IMILUnknown1Impl_Release(IMILUnknown1
*iface
)
690 BitmapImpl
*This
= impl_from_IMILUnknown1(iface
);
691 return IWICBitmap_Release(&This
->IWICBitmap_iface
);
694 DECLSPEC_HIDDEN
void WINAPI
IMILUnknown1Impl_unknown1(IMILUnknown1
*iface
, void *arg
)
696 FIXME("(%p,%p): stub\n", iface
, arg
);
699 static HRESULT WINAPI
IMILUnknown1Impl_unknown2(IMILUnknown1
*iface
, void *arg1
, void *arg2
)
701 FIXME("(%p,%p,%p): stub\n", iface
, arg1
, arg2
);
705 DECLSPEC_HIDDEN HRESULT WINAPI
IMILUnknown1Impl_unknown3(IMILUnknown1
*iface
, void *arg
)
707 FIXME("(%p,%p): stub\n", iface
, arg
);
711 static HRESULT WINAPI
IMILUnknown1Impl_unknown4(IMILUnknown1
*iface
, void *arg
)
713 FIXME("(%p,%p): stub\n", iface
, arg
);
717 static HRESULT WINAPI
IMILUnknown1Impl_unknown5(IMILUnknown1
*iface
, void *arg
)
719 FIXME("(%p,%p): stub\n", iface
, arg
);
723 static HRESULT WINAPI
IMILUnknown1Impl_unknown6(IMILUnknown1
*iface
, DWORD64 arg
)
725 FIXME("(%p,%s): stub\n", iface
, wine_dbgstr_longlong(arg
));
729 static HRESULT WINAPI
IMILUnknown1Impl_unknown7(IMILUnknown1
*iface
, void *arg
)
731 FIXME("(%p,%p): stub\n", iface
, arg
);
735 DECLSPEC_HIDDEN HRESULT WINAPI
IMILUnknown1Impl_unknown8(IMILUnknown1
*iface
)
737 FIXME("(%p): stub\n", iface
);
741 DEFINE_THISCALL_WRAPPER(IMILUnknown1Impl_unknown1
, 8)
742 DEFINE_THISCALL_WRAPPER(IMILUnknown1Impl_unknown3
, 8)
743 DEFINE_THISCALL_WRAPPER(IMILUnknown1Impl_unknown8
, 4)
745 static const IMILUnknown1Vtbl IMILUnknown1Impl_Vtbl
=
747 IMILUnknown1Impl_QueryInterface
,
748 IMILUnknown1Impl_AddRef
,
749 IMILUnknown1Impl_Release
,
750 THISCALL(IMILUnknown1Impl_unknown1
),
751 IMILUnknown1Impl_unknown2
,
752 THISCALL(IMILUnknown1Impl_unknown3
),
753 IMILUnknown1Impl_unknown4
,
754 IMILUnknown1Impl_unknown5
,
755 IMILUnknown1Impl_unknown6
,
756 IMILUnknown1Impl_unknown7
,
757 THISCALL(IMILUnknown1Impl_unknown8
)
760 static HRESULT WINAPI
IMILUnknown2Impl_QueryInterface(IMILUnknown2
*iface
, REFIID iid
,
763 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_guid(iid
), ppv
);
765 return E_NOINTERFACE
;
768 static ULONG WINAPI
IMILUnknown2Impl_AddRef(IMILUnknown2
*iface
)
770 FIXME("(%p): stub\n", iface
);
774 static ULONG WINAPI
IMILUnknown2Impl_Release(IMILUnknown2
*iface
)
776 FIXME("(%p): stub\n", iface
);
780 static HRESULT WINAPI
IMILUnknown2Impl_unknown1(IMILUnknown2
*iface
, void *arg1
, void **arg2
)
782 FIXME("(%p,%p,%p): stub\n", iface
, arg1
, arg2
);
783 if (arg2
) *arg2
= NULL
;
787 static HRESULT WINAPI
IMILUnknown2Impl_unknown2(IMILUnknown2
*iface
, void *arg1
, void *arg2
)
789 FIXME("(%p,%p,%p): stub\n", iface
, arg1
, arg2
);
793 static HRESULT WINAPI
IMILUnknown2Impl_unknown3(IMILUnknown2
*iface
, void *arg1
)
795 FIXME("(%p,%p): stub\n", iface
, arg1
);
799 static const IMILUnknown2Vtbl IMILUnknown2Impl_Vtbl
=
801 IMILUnknown2Impl_QueryInterface
,
802 IMILUnknown2Impl_AddRef
,
803 IMILUnknown2Impl_Release
,
804 IMILUnknown2Impl_unknown1
,
805 IMILUnknown2Impl_unknown2
,
806 IMILUnknown2Impl_unknown3
809 HRESULT
BitmapImpl_Create(UINT uiWidth
, UINT uiHeight
, UINT stride
, UINT datasize
, void *view
,
810 UINT offset
, REFWICPixelFormatGUID pixelFormat
, WICBitmapCreateCacheOption option
,
811 IWICBitmap
**ppIBitmap
)
818 hr
= get_pixelformat_bpp(pixelFormat
, &bpp
);
819 if (FAILED(hr
)) return hr
;
821 if (!stride
) stride
= (((bpp
*uiWidth
)+31)/32)*4;
822 if (!datasize
) datasize
= stride
* uiHeight
;
824 if (datasize
< stride
* uiHeight
) return WINCODEC_ERR_INSUFFICIENTBUFFER
;
825 if (stride
< ((bpp
*uiWidth
)+7)/8) return E_INVALIDARG
;
827 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapImpl
));
828 if (!This
) return E_OUTOFMEMORY
;
830 if (view
) data
= (BYTE
*)view
+ offset
;
831 else if (!(data
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, datasize
)))
833 HeapFree(GetProcessHeap(), 0, This
);
834 return E_OUTOFMEMORY
;
837 This
->IWICBitmap_iface
.lpVtbl
= &BitmapImpl_Vtbl
;
838 This
->IMILBitmapSource_iface
.lpVtbl
= &IMILBitmapImpl_Vtbl
;
839 This
->IMILUnknown1_iface
.lpVtbl
= &IMILUnknown1Impl_Vtbl
;
840 This
->IMILUnknown2_iface
.lpVtbl
= &IMILUnknown2Impl_Vtbl
;
842 This
->palette
= NULL
;
843 This
->palette_set
= 0;
847 This
->offset
= offset
;
848 This
->width
= uiWidth
;
849 This
->height
= uiHeight
;
850 This
->stride
= stride
;
852 memcpy(&This
->pixelformat
, pixelFormat
, sizeof(GUID
));
853 This
->dpix
= This
->dpiy
= 0.0;
854 InitializeCriticalSection(&This
->cs
);
855 This
->cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": BitmapImpl.lock");
857 *ppIBitmap
= &This
->IWICBitmap_iface
;