MCPcopy Create free account
hub / github.com/LegacyUpdate/LegacyUpdate / GetWICBitmap

Function GetWICBitmap

shared/LoadImage.c:78–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78static 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
103end:
104 IWICBitmapDecoder_Release(decoder);
105 return bitmap;
106}
107
108static HBITMAP GetHBitmapForWICBitmap(IWICBitmapSource *bitmap) {
109 HBITMAP hBitmap = NULL;

Callers 2

LoadPNGResourceFunction · 0.85
LoadJPEGFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected