| 394 | } |
| 395 | |
| 396 | int GLTextureManager::loadFileIcon(const GLTextureObject& obj) |
| 397 | { |
| 398 | // ConsoleWriteGuard guard("\t\tloadFileIcon"); |
| 399 | |
| 400 | // initialize COM on this thread for the win32 icon extraction calls |
| 401 | OleInitialize(NULL); |
| 402 | CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); |
| 403 | |
| 404 | // load the icon |
| 405 | int ilImageId = -1; |
| 406 | Gdiplus::Bitmap * bitmap = NULL; |
| 407 | int virtualIconIndex = winOS->GetIconTypeFromFileName(obj.srcPath); |
| 408 | if (virtualIconIndex > -1) |
| 409 | { |
| 410 | // this is a virtual folder |
| 411 | bitmap = winOS->GetIconGraphic(virtualIconIndex); |
| 412 | } |
| 413 | else |
| 414 | { |
| 415 | // this is an icon index |
| 416 | bitmap = winOS->GetIconGraphic(obj.srcPath); |
| 417 | } |
| 418 | |
| 419 | if (bitmap) |
| 420 | { |
| 421 | // convert/copy the bitmap into a devil image |
| 422 | unsigned int width = bitmap->GetWidth(); |
| 423 | unsigned int height = bitmap->GetHeight(); |
| 424 | Gdiplus::Rect bitmapRect(0, 0, width, height); |
| 425 | Gdiplus::BitmapData * bitmapData = new Gdiplus::BitmapData; |
| 426 | if (Gdiplus::Ok == bitmap->LockBits(&bitmapRect, Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, bitmapData)) |
| 427 | { |
| 428 | TRY_SLEEP_LOCK(_ilMutex) |
| 429 | int imgId = ilGenImage(); |
| 430 | ilBindImage(imgId); |
| 431 | if (ilTexImage(width, height, 1, 4, IL_BGRA, IL_UNSIGNED_BYTE, bitmapData->Scan0)) |
| 432 | ilImageId = imgId; |
| 433 | else |
| 434 | ilDeleteImage(imgId); |
| 435 | _ilMutex.unlock(); |
| 436 | bitmap->UnlockBits(bitmapData); |
| 437 | } |
| 438 | SAFE_DELETE(bitmapData); |
| 439 | SAFE_DELETE(bitmap); |
| 440 | } |
| 441 | |
| 442 | // uninitialize |
| 443 | CoUninitialize(); |
| 444 | OleUninitialize(); |
| 445 | IL_ASSERT_NO_ERROR(); |
| 446 | return ilImageId; |
| 447 | } |
| 448 | |
| 449 | int GLTextureManager::loadSampledImage(const GLTextureObject& obj) |
| 450 | { |
nothing calls this directly
no test coverage detected