| 76 | } |
| 77 | |
| 78 | static IWICBitmapSource *GetWICBitmap(IStream *imageStream, REFCLSID rclsid) { |
| 79 | IWICBitmapSource *bitmap = NULL; |
| 80 | IWICBitmapDecoder *decoder = NULL; |
| 81 | UINT frameCount = 0; |
| 82 | IWICBitmapFrameDecode *frame = NULL; |
| 83 | |
| 84 | if (!SUCCEEDED(CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IWICBitmapDecoder, (LPVOID *)&decoder))) { |
| 85 | return NULL; |
| 86 | } |
| 87 | |
| 88 | if (!SUCCEEDED(IWICBitmapDecoder_Initialize(decoder, imageStream, WICDecodeMetadataCacheOnLoad))) { |
| 89 | goto end; |
| 90 | } |
| 91 | |
| 92 | if (!SUCCEEDED(IWICBitmapDecoder_GetFrameCount(decoder, &frameCount)) || frameCount != 1) { |
| 93 | goto end; |
| 94 | } |
| 95 | |
| 96 | if (!SUCCEEDED(IWICBitmapDecoder_GetFrame(decoder, 0, &frame))) { |
| 97 | goto end; |
| 98 | } |
| 99 | |
| 100 | $WICConvertBitmapSource(&GUID_WICPixelFormat32bppPBGRA, (IWICBitmapSource *)frame, &bitmap); |
| 101 | IWICBitmapFrameDecode_Release(frame); |
| 102 | |
| 103 | end: |
| 104 | IWICBitmapDecoder_Release(decoder); |
| 105 | return bitmap; |
| 106 | } |
| 107 | |
| 108 | static HBITMAP GetHBitmapForWICBitmap(IWICBitmapSource *bitmap) { |
| 109 | HBITMAP hBitmap = NULL; |
no outgoing calls
no test coverage detected