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
19 #include "wincodecs_private.h"
21 /* WARNING: .NET Media Integration Layer (MIL) directly dereferences
22 * BitmapImpl members and depends on its exact layout.
24 typedef struct BitmapImpl
{
25 IMILUnknown1 IMILUnknown1_iface
;
27 IMILBitmapSource IMILBitmapSource_iface
;
28 IWICBitmap IWICBitmap_iface
;
29 IMILUnknown2 IMILUnknown2_iface
;
32 LONG lock
; /* 0 if not locked, -1 if locked for writing, count if locked for reading */
37 WICPixelFormatGUID pixelformat
;
42 typedef struct BitmapLockImpl
{
43 IWICBitmapLock IWICBitmapLock_iface
;
50 static inline BitmapImpl
*impl_from_IWICBitmap(IWICBitmap
*iface
)
52 return CONTAINING_RECORD(iface
, BitmapImpl
, IWICBitmap_iface
);
55 static inline BitmapImpl
*impl_from_IMILBitmapSource(IMILBitmapSource
*iface
)
57 return CONTAINING_RECORD(iface
, BitmapImpl
, IMILBitmapSource_iface
);
60 static inline BitmapImpl
*impl_from_IMILUnknown1(IMILUnknown1
*iface
)
62 return CONTAINING_RECORD(iface
, BitmapImpl
, IMILUnknown1_iface
);
65 static inline BitmapImpl
*impl_from_IMILUnknown2(IMILUnknown2
*iface
)
67 return CONTAINING_RECORD(iface
, BitmapImpl
, IMILUnknown2_iface
);
70 static inline BitmapLockImpl
*impl_from_IWICBitmapLock(IWICBitmapLock
*iface
)
72 return CONTAINING_RECORD(iface
, BitmapLockImpl
, IWICBitmapLock_iface
);
75 static BOOL
BitmapImpl_AcquireLock(BitmapImpl
*This
, int write
)
79 return 0 == InterlockedCompareExchange(&This
->lock
, -1, 0);
85 LONG prev_val
= This
->lock
;
88 if (prev_val
== InterlockedCompareExchange(&This
->lock
, prev_val
+1, prev_val
))
94 static void BitmapImpl_ReleaseLock(BitmapImpl
*This
)
98 LONG prev_val
= This
->lock
, new_val
;
102 new_val
= prev_val
- 1;
103 if (prev_val
== InterlockedCompareExchange(&This
->lock
, new_val
, prev_val
))
109 static HRESULT WINAPI
BitmapLockImpl_QueryInterface(IWICBitmapLock
*iface
, REFIID iid
,
112 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
113 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
115 if (!ppv
) return E_INVALIDARG
;
117 if (IsEqualIID(&IID_IUnknown
, iid
) ||
118 IsEqualIID(&IID_IWICBitmapLock
, iid
))
120 *ppv
= &This
->IWICBitmapLock_iface
;
125 return E_NOINTERFACE
;
128 IUnknown_AddRef((IUnknown
*)*ppv
);
132 static ULONG WINAPI
BitmapLockImpl_AddRef(IWICBitmapLock
*iface
)
134 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
135 ULONG ref
= InterlockedIncrement(&This
->ref
);
137 TRACE("(%p) refcount=%u\n", iface
, ref
);
142 static ULONG WINAPI
BitmapLockImpl_Release(IWICBitmapLock
*iface
)
144 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
145 ULONG ref
= InterlockedDecrement(&This
->ref
);
147 TRACE("(%p) refcount=%u\n", iface
, ref
);
151 BitmapImpl_ReleaseLock(This
->parent
);
152 IWICBitmap_Release(&This
->parent
->IWICBitmap_iface
);
153 HeapFree(GetProcessHeap(), 0, This
);
159 static HRESULT WINAPI
BitmapLockImpl_GetSize(IWICBitmapLock
*iface
,
160 UINT
*puiWidth
, UINT
*puiHeight
)
162 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
163 TRACE("(%p,%p,%p)\n", iface
, puiWidth
, puiHeight
);
165 if (!puiWidth
|| !puiHeight
)
168 *puiWidth
= This
->width
;
169 *puiHeight
= This
->height
;
174 static HRESULT WINAPI
BitmapLockImpl_GetStride(IWICBitmapLock
*iface
,
177 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
178 TRACE("(%p,%p)\n", iface
, pcbStride
);
183 *pcbStride
= This
->parent
->stride
;
188 static HRESULT WINAPI
BitmapLockImpl_GetDataPointer(IWICBitmapLock
*iface
,
189 UINT
*pcbBufferSize
, BYTE
**ppbData
)
191 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
192 TRACE("(%p,%p,%p)\n", iface
, pcbBufferSize
, ppbData
);
194 if (!pcbBufferSize
|| !ppbData
)
197 *pcbBufferSize
= This
->parent
->stride
* (This
->height
- 1) +
198 ((This
->parent
->bpp
* This
->width
) + 7)/8;
199 *ppbData
= This
->data
;
204 static HRESULT WINAPI
BitmapLockImpl_GetPixelFormat(IWICBitmapLock
*iface
,
205 WICPixelFormatGUID
*pPixelFormat
)
207 BitmapLockImpl
*This
= impl_from_IWICBitmapLock(iface
);
208 TRACE("(%p,%p)\n", iface
, pPixelFormat
);
210 return IWICBitmap_GetPixelFormat(&This
->parent
->IWICBitmap_iface
, pPixelFormat
);
213 static const IWICBitmapLockVtbl BitmapLockImpl_Vtbl
= {
214 BitmapLockImpl_QueryInterface
,
215 BitmapLockImpl_AddRef
,
216 BitmapLockImpl_Release
,
217 BitmapLockImpl_GetSize
,
218 BitmapLockImpl_GetStride
,
219 BitmapLockImpl_GetDataPointer
,
220 BitmapLockImpl_GetPixelFormat
223 static HRESULT WINAPI
BitmapImpl_QueryInterface(IWICBitmap
*iface
, REFIID iid
,
226 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
227 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
229 if (!ppv
) return E_INVALIDARG
;
231 if (IsEqualIID(&IID_IUnknown
, iid
) ||
232 IsEqualIID(&IID_IWICBitmapSource
, iid
) ||
233 IsEqualIID(&IID_IWICBitmap
, iid
))
235 *ppv
= &This
->IWICBitmap_iface
;
237 else if (IsEqualIID(&IID_IMILBitmapSource
, iid
))
239 *ppv
= &This
->IMILBitmapSource_iface
;
244 return E_NOINTERFACE
;
247 IUnknown_AddRef((IUnknown
*)*ppv
);
251 static ULONG WINAPI
BitmapImpl_AddRef(IWICBitmap
*iface
)
253 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
254 ULONG ref
= InterlockedIncrement(&This
->ref
);
256 TRACE("(%p) refcount=%u\n", iface
, ref
);
261 static ULONG WINAPI
BitmapImpl_Release(IWICBitmap
*iface
)
263 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
264 ULONG ref
= InterlockedDecrement(&This
->ref
);
266 TRACE("(%p) refcount=%u\n", iface
, ref
);
270 if (This
->palette
) IWICPalette_Release(This
->palette
);
271 This
->cs
.DebugInfo
->Spare
[0] = 0;
272 DeleteCriticalSection(&This
->cs
);
273 HeapFree(GetProcessHeap(), 0, This
->data
);
274 HeapFree(GetProcessHeap(), 0, This
);
280 static HRESULT WINAPI
BitmapImpl_GetSize(IWICBitmap
*iface
,
281 UINT
*puiWidth
, UINT
*puiHeight
)
283 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
284 TRACE("(%p,%p,%p)\n", iface
, puiWidth
, puiHeight
);
286 if (!puiWidth
|| !puiHeight
)
289 *puiWidth
= This
->width
;
290 *puiHeight
= This
->height
;
295 static HRESULT WINAPI
BitmapImpl_GetPixelFormat(IWICBitmap
*iface
,
296 WICPixelFormatGUID
*pPixelFormat
)
298 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
299 TRACE("(%p,%p)\n", iface
, pPixelFormat
);
304 memcpy(pPixelFormat
, &This
->pixelformat
, sizeof(GUID
));
309 static HRESULT WINAPI
BitmapImpl_GetResolution(IWICBitmap
*iface
,
310 double *pDpiX
, double *pDpiY
)
312 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
313 TRACE("(%p,%p,%p)\n", iface
, pDpiX
, pDpiY
);
315 if (!pDpiX
|| !pDpiY
)
318 EnterCriticalSection(&This
->cs
);
321 LeaveCriticalSection(&This
->cs
);
326 static HRESULT WINAPI
BitmapImpl_CopyPalette(IWICBitmap
*iface
,
327 IWICPalette
*pIPalette
)
329 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
330 TRACE("(%p,%p)\n", iface
, pIPalette
);
332 if (!This
->palette_set
)
333 return WINCODEC_ERR_PALETTEUNAVAILABLE
;
335 return IWICPalette_InitializeFromPalette(pIPalette
, This
->palette
);
338 static HRESULT WINAPI
BitmapImpl_CopyPixels(IWICBitmap
*iface
,
339 const WICRect
*prc
, UINT cbStride
, UINT cbBufferSize
, BYTE
*pbBuffer
)
341 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
342 TRACE("(%p,%p,%u,%u,%p)\n", iface
, prc
, cbStride
, cbBufferSize
, pbBuffer
);
344 return copy_pixels(This
->bpp
, This
->data
, This
->width
, This
->height
,
345 This
->stride
, prc
, cbStride
, cbBufferSize
, pbBuffer
);
348 static HRESULT WINAPI
BitmapImpl_Lock(IWICBitmap
*iface
, const WICRect
*prcLock
,
349 DWORD flags
, IWICBitmapLock
**ppILock
)
351 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
352 BitmapLockImpl
*result
;
355 TRACE("(%p,%p,%x,%p)\n", iface
, prcLock
, flags
, ppILock
);
357 if (!(flags
& (WICBitmapLockRead
|WICBitmapLockWrite
)) || !ppILock
)
363 rc
.Width
= This
->width
;
364 rc
.Height
= This
->height
;
367 else if (prcLock
->X
>= This
->width
|| prcLock
->Y
>= This
->height
||
368 prcLock
->X
+ prcLock
->Width
> This
->width
||
369 prcLock
->Y
+ prcLock
->Height
> This
->height
||
370 prcLock
->Width
<= 0 || prcLock
->Height
<= 0)
372 else if (((prcLock
->X
* This
->bpp
) % 8) != 0)
374 FIXME("Cannot lock at an X coordinate not at a full byte\n");
378 result
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapLockImpl
));
380 return E_OUTOFMEMORY
;
382 if (!BitmapImpl_AcquireLock(This
, flags
& WICBitmapLockWrite
))
384 HeapFree(GetProcessHeap(), 0, result
);
385 return WINCODEC_ERR_ALREADYLOCKED
;
388 result
->IWICBitmapLock_iface
.lpVtbl
= &BitmapLockImpl_Vtbl
;
390 result
->parent
= This
;
391 result
->width
= prcLock
->Width
;
392 result
->height
= prcLock
->Height
;
393 result
->data
= This
->data
+ This
->stride
* prcLock
->Y
+
394 (This
->bpp
* prcLock
->X
)/8;
396 IWICBitmap_AddRef(&This
->IWICBitmap_iface
);
397 *ppILock
= &result
->IWICBitmapLock_iface
;
402 static HRESULT WINAPI
BitmapImpl_SetPalette(IWICBitmap
*iface
, IWICPalette
*pIPalette
)
404 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
407 TRACE("(%p,%p)\n", iface
, pIPalette
);
411 IWICPalette
*new_palette
;
412 hr
= PaletteImpl_Create(&new_palette
);
414 if (FAILED(hr
)) return hr
;
416 if (InterlockedCompareExchangePointer((void**)&This
->palette
, new_palette
, NULL
))
418 /* someone beat us to it */
419 IWICPalette_Release(new_palette
);
423 hr
= IWICPalette_InitializeFromPalette(This
->palette
, pIPalette
);
426 This
->palette_set
= 1;
431 static HRESULT WINAPI
BitmapImpl_SetResolution(IWICBitmap
*iface
,
432 double dpiX
, double dpiY
)
434 BitmapImpl
*This
= impl_from_IWICBitmap(iface
);
435 TRACE("(%p,%f,%f)\n", iface
, dpiX
, dpiY
);
437 EnterCriticalSection(&This
->cs
);
440 LeaveCriticalSection(&This
->cs
);
445 static const IWICBitmapVtbl BitmapImpl_Vtbl
= {
446 BitmapImpl_QueryInterface
,
450 BitmapImpl_GetPixelFormat
,
451 BitmapImpl_GetResolution
,
452 BitmapImpl_CopyPalette
,
453 BitmapImpl_CopyPixels
,
455 BitmapImpl_SetPalette
,
456 BitmapImpl_SetResolution
459 static HRESULT WINAPI
IMILBitmapImpl_QueryInterface(IMILBitmapSource
*iface
, REFIID iid
,
462 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
463 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
465 if (!ppv
) return E_INVALIDARG
;
467 if (IsEqualIID(&IID_IUnknown
, iid
) ||
468 IsEqualIID(&IID_IMILBitmapSource
, iid
))
470 IUnknown_AddRef(&This
->IMILBitmapSource_iface
);
471 *ppv
= &This
->IMILBitmapSource_iface
;
476 return E_NOINTERFACE
;
479 static ULONG WINAPI
IMILBitmapImpl_AddRef(IMILBitmapSource
*iface
)
481 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
482 return IWICBitmap_AddRef(&This
->IWICBitmap_iface
);
485 static ULONG WINAPI
IMILBitmapImpl_Release(IMILBitmapSource
*iface
)
487 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
488 return IWICBitmap_Release(&This
->IWICBitmap_iface
);
491 static HRESULT WINAPI
IMILBitmapImpl_GetSize(IMILBitmapSource
*iface
,
492 UINT
*width
, UINT
*height
)
494 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
495 return IWICBitmap_GetSize(&This
->IWICBitmap_iface
, width
, height
);
500 const GUID
*WIC_format
;
504 { &GUID_WICPixelFormatDontCare
, 0 },
505 { &GUID_WICPixelFormat1bppIndexed
, 1 },
506 { &GUID_WICPixelFormat2bppIndexed
, 2 },
507 { &GUID_WICPixelFormat4bppIndexed
, 3 },
508 { &GUID_WICPixelFormat8bppIndexed
, 4 },
509 { &GUID_WICPixelFormatBlackWhite
, 5 },
510 { &GUID_WICPixelFormat2bppGray
, 6 },
511 { &GUID_WICPixelFormat4bppGray
, 7 },
512 { &GUID_WICPixelFormat8bppGray
, 8 },
513 { &GUID_WICPixelFormat16bppBGR555
, 9 },
514 { &GUID_WICPixelFormat16bppBGR565
, 0x0a },
515 { &GUID_WICPixelFormat16bppGray
, 0x0b },
516 { &GUID_WICPixelFormat24bppBGR
, 0x0c },
517 { &GUID_WICPixelFormat24bppRGB
, 0x0d },
518 { &GUID_WICPixelFormat32bppBGR
, 0x0e },
519 { &GUID_WICPixelFormat32bppBGRA
, 0x0f },
520 { &GUID_WICPixelFormat32bppPBGRA
, 0x10 },
521 { &GUID_WICPixelFormat48bppRGB
, 0x15 },
522 { &GUID_WICPixelFormat64bppRGBA
, 0x16 },
523 { &GUID_WICPixelFormat64bppPRGBA
, 0x17 },
524 { &GUID_WICPixelFormat32bppCMYK
, 0x1c }
527 static HRESULT WINAPI
IMILBitmapImpl_GetPixelFormat(IMILBitmapSource
*iface
,
530 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
533 TRACE("(%p,%p)\n", iface
, format
);
535 if (!format
) return E_INVALIDARG
;
539 for (i
= 0; i
< sizeof(pixel_fmt_map
)/sizeof(pixel_fmt_map
[0]); i
++)
541 if (IsEqualGUID(pixel_fmt_map
[i
].WIC_format
, &This
->pixelformat
))
543 *format
= pixel_fmt_map
[i
].enum_format
;
551 static HRESULT WINAPI
IMILBitmapImpl_GetResolution(IMILBitmapSource
*iface
,
552 double *dpix
, double *dpiy
)
554 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
555 return IWICBitmap_GetResolution(&This
->IWICBitmap_iface
, dpix
, dpiy
);
558 static HRESULT WINAPI
IMILBitmapImpl_CopyPalette(IMILBitmapSource
*iface
,
559 IWICPalette
*palette
)
561 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
562 return IWICBitmap_CopyPalette(&This
->IWICBitmap_iface
, palette
);
565 static HRESULT WINAPI
IMILBitmapImpl_CopyPixels(IMILBitmapSource
*iface
,
566 const WICRect
*rc
, UINT stride
, UINT size
, BYTE
*buffer
)
568 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
569 return IWICBitmap_CopyPixels(&This
->IWICBitmap_iface
, rc
, stride
, size
, buffer
);
572 static HRESULT WINAPI
IMILBitmapImpl_UnknownMethod1(IMILBitmapSource
*iface
, void **ppv
)
574 BitmapImpl
*This
= impl_from_IMILBitmapSource(iface
);
576 TRACE("(%p,%p)\n", iface
, ppv
);
578 if (!ppv
) return E_INVALIDARG
;
580 IUnknown_AddRef(&This
->IMILUnknown1_iface
);
581 *ppv
= &This
->IMILUnknown1_iface
;
586 static const IMILBitmapSourceVtbl IMILBitmapImpl_Vtbl
=
588 IMILBitmapImpl_QueryInterface
,
589 IMILBitmapImpl_AddRef
,
590 IMILBitmapImpl_Release
,
591 IMILBitmapImpl_GetSize
,
592 IMILBitmapImpl_GetPixelFormat
,
593 IMILBitmapImpl_GetResolution
,
594 IMILBitmapImpl_CopyPalette
,
595 IMILBitmapImpl_CopyPixels
,
596 IMILBitmapImpl_UnknownMethod1
,
599 static HRESULT WINAPI
IMILUnknown1Impl_QueryInterface(IMILUnknown1
*iface
, REFIID iid
,
602 BitmapImpl
*This
= impl_from_IMILUnknown1(iface
);
604 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
606 if (!ppv
) return E_INVALIDARG
;
608 if (IsEqualIID(&IID_IUnknown
, iid
))
610 IUnknown_AddRef(&This
->IMILUnknown1_iface
);
615 return IWICBitmap_QueryInterface(&This
->IWICBitmap_iface
, iid
, ppv
);
618 static ULONG WINAPI
IMILUnknown1Impl_AddRef(IMILUnknown1
*iface
)
620 BitmapImpl
*This
= impl_from_IMILUnknown1(iface
);
621 return IWICBitmap_AddRef(&This
->IWICBitmap_iface
);
624 static ULONG WINAPI
IMILUnknown1Impl_Release(IMILUnknown1
*iface
)
626 BitmapImpl
*This
= impl_from_IMILUnknown1(iface
);
627 return IWICBitmap_Release(&This
->IWICBitmap_iface
);
630 static const IMILUnknown1Vtbl IMILUnknown1Impl_Vtbl
=
632 IMILUnknown1Impl_QueryInterface
,
633 IMILUnknown1Impl_AddRef
,
634 IMILUnknown1Impl_Release
,
637 static HRESULT WINAPI
IMILUnknown2Impl_QueryInterface(IMILUnknown2
*iface
, REFIID iid
,
640 BitmapImpl
*This
= impl_from_IMILUnknown2(iface
);
642 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
644 if (!ppv
) return E_INVALIDARG
;
646 if (IsEqualIID(&IID_IUnknown
, iid
))
648 IUnknown_AddRef(&This
->IMILUnknown2_iface
);
653 return IWICBitmap_QueryInterface(&This
->IWICBitmap_iface
, iid
, ppv
);
656 static ULONG WINAPI
IMILUnknown2Impl_AddRef(IMILUnknown2
*iface
)
658 BitmapImpl
*This
= impl_from_IMILUnknown2(iface
);
659 return IWICBitmap_AddRef(&This
->IWICBitmap_iface
);
662 static ULONG WINAPI
IMILUnknown2Impl_Release(IMILUnknown2
*iface
)
664 BitmapImpl
*This
= impl_from_IMILUnknown2(iface
);
665 return IWICBitmap_Release(&This
->IWICBitmap_iface
);
668 static HRESULT WINAPI
IMILUnknown2Impl_UnknownMethod1(IMILUnknown2
*iface
, void *arg1
, void *arg2
)
670 FIXME("(%p,%p,%p): stub\n", iface
, arg1
, arg2
);
674 static const IMILUnknown2Vtbl IMILUnknown2Impl_Vtbl
=
676 IMILUnknown2Impl_QueryInterface
,
677 IMILUnknown2Impl_AddRef
,
678 IMILUnknown2Impl_Release
,
679 IMILUnknown2Impl_UnknownMethod1
,
682 HRESULT
BitmapImpl_Create(UINT uiWidth
, UINT uiHeight
,
683 UINT stride
, UINT datasize
, BYTE
*bits
,
684 REFWICPixelFormatGUID pixelFormat
, WICBitmapCreateCacheOption option
,
685 IWICBitmap
**ppIBitmap
)
692 hr
= get_pixelformat_bpp(pixelFormat
, &bpp
);
693 if (FAILED(hr
)) return hr
;
695 if (!stride
) stride
= (((bpp
*uiWidth
)+31)/32)*4;
696 if (!datasize
) datasize
= stride
* uiHeight
;
698 if (datasize
< stride
* uiHeight
) return WINCODEC_ERR_INSUFFICIENTBUFFER
;
699 if (stride
< ((bpp
*uiWidth
)+7)/8) return E_INVALIDARG
;
701 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapImpl
));
702 data
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, datasize
);
705 HeapFree(GetProcessHeap(), 0, This
);
706 HeapFree(GetProcessHeap(), 0, data
);
707 return E_OUTOFMEMORY
;
709 if (bits
) memcpy(data
, bits
, datasize
);
711 This
->IWICBitmap_iface
.lpVtbl
= &BitmapImpl_Vtbl
;
712 This
->IMILBitmapSource_iface
.lpVtbl
= &IMILBitmapImpl_Vtbl
;
713 This
->IMILUnknown1_iface
.lpVtbl
= &IMILUnknown1Impl_Vtbl
;
714 This
->IMILUnknown2_iface
.lpVtbl
= &IMILUnknown2Impl_Vtbl
;
716 This
->palette
= NULL
;
717 This
->palette_set
= 0;
720 This
->width
= uiWidth
;
721 This
->height
= uiHeight
;
722 This
->stride
= stride
;
724 memcpy(&This
->pixelformat
, pixelFormat
, sizeof(GUID
));
725 This
->dpix
= This
->dpiy
= 0.0;
726 InitializeCriticalSection(&This
->cs
);
727 This
->cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": BitmapImpl.lock");
729 *ppIBitmap
= &This
->IWICBitmap_iface
;