MCPcopy Create free account
hub / github.com/cinience/RedisStudio / LoadImage

Method LoadImage

DuiLib/Core/UIRender.cpp:286–440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286TImageInfo* CRenderEngine::LoadImage(STRINGorID bitmap, LPCTSTR type, DWORD mask)
287{
288 LPBYTE pData = NULL;
289 DWORD dwSize = 0;
290
291 do
292 {
293 if( type == NULL ) {
294 CDuiString sFile = CPaintManagerUI::GetResourcePath();
295 if( CPaintManagerUI::GetResourceZip().IsEmpty() ) {
296 sFile += bitmap.m_lpstr;
297 HANDLE hFile = ::CreateFile(sFile.GetData(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, \
298 FILE_ATTRIBUTE_NORMAL, NULL);
299 if( hFile == INVALID_HANDLE_VALUE ) break;
300 dwSize = ::GetFileSize(hFile, NULL);
301 if( dwSize == 0 ) break;
302
303 DWORD dwRead = 0;
304 pData = new BYTE[ dwSize ];
305 ::ReadFile( hFile, pData, dwSize, &dwRead, NULL );
306 ::CloseHandle( hFile );
307
308 if( dwRead != dwSize ) {
309 delete[] pData;
310 pData = NULL;
311 break;
312 }
313 }
314 else {
315 sFile += CPaintManagerUI::GetResourceZip();
316 HZIP hz = NULL;
317 if( CPaintManagerUI::IsCachedResourceZip() ) hz = (HZIP)CPaintManagerUI::GetResourceZipHandle();
318 else hz = OpenZip((void*)sFile.GetData(), 0, 2);
319 if( hz == NULL ) break;
320 ZIPENTRY ze;
321 int i;
322 if( FindZipItem(hz, bitmap.m_lpstr, true, &i, &ze) != 0 ) break;
323 dwSize = ze.unc_size;
324 if( dwSize == 0 ) break;
325 pData = new BYTE[ dwSize ];
326 int res = UnzipItem(hz, i, pData, dwSize, 3);
327 if( res != 0x00000000 && res != 0x00000600) {
328 delete[] pData;
329 pData = NULL;
330 if( !CPaintManagerUI::IsCachedResourceZip() ) CloseZip(hz);
331 break;
332 }
333 if( !CPaintManagerUI::IsCachedResourceZip() ) CloseZip(hz);
334 }
335 }
336 else {
337 HRSRC hResource = ::FindResource(CPaintManagerUI::GetResourceDll(), bitmap.m_lpstr, type);
338 if( hResource == NULL ) break;
339 HGLOBAL hGlobal = ::LoadResource(CPaintManagerUI::GetResourceDll(), hResource);
340 if( hGlobal == NULL ) {
341 FreeResource(hResource);
342 break;
343 }

Callers

nothing calls this directly

Calls 5

UnzipItemFunction · 0.85
stbi_load_from_memoryFunction · 0.85
stbi_image_freeFunction · 0.85
IsEmptyMethod · 0.80
GetDataMethod · 0.45

Tested by

no test coverage detected