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

Function LoadPNGResource

shared/LoadImage.c:142–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142HBITMAP LoadPNGResource(HINSTANCE hInstance, LPCWSTR resourceName, LPCWSTR resourceType) {
143 if (!$WICConvertBitmapSource) {
144 HMODULE windowscodecs = LoadLibrary(L"windowscodecs.dll");
145 if (windowscodecs) {
146 $WICConvertBitmapSource = (_WICConvertBitmapSource)GetProcAddress(windowscodecs, "WICConvertBitmapSource");
147 }
148 if (!$WICConvertBitmapSource) {
149 return NULL;
150 }
151 }
152
153 IStream *imageStream = GetResourceStream(hInstance, resourceName, resourceType);
154 HRESULT hr = S_OK;
155 if (!imageStream) {
156 hr = HRESULT_FROM_WIN32(GetLastError());
157 CHECK_HR(L"GetResourceStream failed");
158 return NULL;
159 }
160
161 IWICBitmapSource *bitmap = GetWICBitmap(imageStream, &CLSID_WICPngDecoder);
162 if (!bitmap) {
163 hr = HRESULT_FROM_WIN32(GetLastError());
164 CHECK_HR(L"GetWICBitmap failed");
165 IStream_Release(imageStream);
166 return NULL;
167 }
168
169 HBITMAP result = GetHBitmapForWICBitmap(bitmap);
170 IWICBitmapSource_Release(bitmap);
171 IStream_Release(imageStream);
172 return result;
173}
174
175HBITMAP LoadJPEGFile(LPCWSTR filePath) {
176 if (!$WICConvertBitmapSource) {

Callers 2

CreateRunOnceWindowFunction · 0.85
ConfigureWindowFunction · 0.85

Calls 3

GetResourceStreamFunction · 0.85
GetWICBitmapFunction · 0.85
GetHBitmapForWICBitmapFunction · 0.85

Tested by

no test coverage detected