diff options
Diffstat (limited to 'lib/Thumbnail/thumbnail.cpp')
-rw-r--r-- | lib/Thumbnail/thumbnail.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Thumbnail/thumbnail.cpp b/lib/Thumbnail/thumbnail.cpp index 0c7162b9..284d1093 100644 --- a/lib/Thumbnail/thumbnail.cpp +++ b/lib/Thumbnail/thumbnail.cpp @@ -118,8 +118,13 @@ thumb::HICON thumb::getThumbnail(const wchar_t* filename, int requestedSize) //r &bmpInfo) == 0) //__out LPVOID lpvObject return nullptr; - HBITMAP bitmapMask = ::CreateCompatibleBitmap(::GetDC(nullptr), bmpInfo.bmWidth, bmpInfo.bmHeight); - if (bitmapMask == 0) + HDC hDC = ::GetDC(nullptr); + if (!hDC) + return nullptr; + ZEN_ON_SCOPE_EXIT(::ReleaseDC(nullptr, hDC)); + + HBITMAP bitmapMask = ::CreateCompatibleBitmap(hDC, bmpInfo.bmWidth, bmpInfo.bmHeight); + if (!bitmapMask) return nullptr; ZEN_ON_SCOPE_EXIT(::DeleteObject(bitmapMask)); @@ -156,7 +161,7 @@ thumb::HICON thumb::getIconByIndex(int iconIndex, int shilIconType) //return 0 o ::HICON hIcon = nullptr; //perf: 1,5 ms - the dominant block { HRESULT hr = imageList->GetIcon(iconIndex, // [in] int i, - hasAlpha ? ILD_IMAGE : ILD_NORMAL, // [in] UINT flags, + (hasAlpha ? ILD_IMAGE : ILD_NORMAL), // [in] UINT flags, //ILD_IMAGE -> do not draw mask - fixes glitch with ILD_NORMAL where both mask *and* alpha channel are applied, e.g. for ffs_batch and folder icon //other flags: http://msdn.microsoft.com/en-us/library/windows/desktop/bb775230(v=vs.85).aspx &hIcon); // [out] HICON *picon |