diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:19:14 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:19:14 +0200 |
commit | 01eb8253196672c969a39587e90b49321a182428 (patch) | |
tree | 4a3b71d7913de519744466c9227fda6461c4f0b5 /lib/Thumbnail/thumbnail.cpp | |
parent | 5.0 (diff) | |
download | FreeFileSync-01eb8253196672c969a39587e90b49321a182428.tar.gz FreeFileSync-01eb8253196672c969a39587e90b49321a182428.tar.bz2 FreeFileSync-01eb8253196672c969a39587e90b49321a182428.zip |
5.1
Diffstat (limited to 'lib/Thumbnail/thumbnail.cpp')
-rw-r--r-- | lib/Thumbnail/thumbnail.cpp | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/lib/Thumbnail/thumbnail.cpp b/lib/Thumbnail/thumbnail.cpp index 050251de..0176f89b 100644 --- a/lib/Thumbnail/thumbnail.cpp +++ b/lib/Thumbnail/thumbnail.cpp @@ -31,59 +31,59 @@ thumb::HICON thumb::getThumbnail(const wchar_t* filename, int requestedSize) //r { HRESULT hr = ::SHGetDesktopFolder(shellFolder.init()); if (FAILED(hr) || !shellFolder) - return NULL; + return nullptr; } - PIDLIST_RELATIVE pidlFolder = NULL; + PIDLIST_RELATIVE pidlFolder = nullptr; { const std::wstring& pathName = beforeLast(filenameStr, '\\'); - HRESULT hr = shellFolder->ParseDisplayName(NULL, // [in] HWND hwnd, - NULL, // [in] IBindCtx *pbc, + HRESULT hr = shellFolder->ParseDisplayName(nullptr, // [in] HWND hwnd, + nullptr, // [in] IBindCtx *pbc, const_cast<LPWSTR>(pathName.c_str()), // [in] LPWSTR pszDisplayName, - NULL, // [out] ULONG *pchEaten, - &pidlFolder, // [out] PIDLIST_RELATIVE* ppidl, - NULL); // [in, out] ULONG *pdwAttributes + nullptr, // [out] ULONG *pchEaten, + &pidlFolder, // [out] PIDLIST_RELATIVE* ppidl, + nullptr); // [in, out] ULONG *pdwAttributes if (FAILED(hr) || !pidlFolder) - return NULL; + return nullptr; } - ZEN_ON_BLOCK_EXIT(::ILFree(pidlFolder)); //older version: ::CoTaskMemFree + ZEN_ON_SCOPE_EXIT(::ILFree(pidlFolder)); //older version: ::CoTaskMemFree ComPtr<IShellFolder> imageFolder; { HRESULT hr = shellFolder->BindToObject(pidlFolder, // [in] PCUIDLIST_RELATIVE pidl, - NULL, + nullptr, IID_PPV_ARGS(imageFolder.init())); if (FAILED(hr) || !imageFolder) - return NULL; + return nullptr; } - PIDLIST_RELATIVE pidImage = NULL; + PIDLIST_RELATIVE pidImage = nullptr; { const std::wstring& shortName = afterLast(filenameStr, '\\'); - HRESULT hr = imageFolder->ParseDisplayName(NULL, // [in] HWND hwnd, - NULL, // [in] IBindCtx *pbc, + HRESULT hr = imageFolder->ParseDisplayName(nullptr, // [in] HWND hwnd, + nullptr, // [in] IBindCtx *pbc, const_cast<LPWSTR>(shortName.c_str()), // [in] LPWSTR pszDisplayName, - NULL, // [out] ULONG *pchEaten, - &pidImage, // [out] PIDLIST_RELATIVE *ppidl, - NULL); // [in, out] ULONG *pdwAttributes + nullptr, // [out] ULONG *pchEaten, + &pidImage, // [out] PIDLIST_RELATIVE *ppidl, + nullptr); // [in, out] ULONG *pdwAttributes if (FAILED(hr) || !pidImage) - return NULL; + return nullptr; } - ZEN_ON_BLOCK_EXIT(::ILFree(pidImage)); //older version: ::CoTaskMemFree + ZEN_ON_SCOPE_EXIT(::ILFree(pidImage)); //older version: ::CoTaskMemFree ComPtr<IExtractImage> extractImage; { PCUITEMID_CHILD_ARRAY pidlIn = reinterpret_cast<PCUITEMID_CHILD_ARRAY>(&pidImage); //this is where STRICT_TYPED_ITEMIDS gets us ;) - HRESULT hr = imageFolder->GetUIObjectOf(NULL, // [in] HWND hwndOwner, + HRESULT hr = imageFolder->GetUIObjectOf(nullptr, // [in] HWND hwndOwner, 1, // [in] UINT cidl, pidlIn, // [in] PCUITEMID_CHILD_ARRAY apidl, IID_IExtractImage, // [in] REFIID riid, - NULL, // [in, out] UINT *rgfReserved, + nullptr, // [in, out] UINT *rgfReserved, reinterpret_cast<void**>(extractImage.init())); // [out] void **ppv if (FAILED(hr) || !extractImage) - return NULL; + return nullptr; } { @@ -100,28 +100,28 @@ thumb::HICON thumb::getThumbnail(const wchar_t* filename, int requestedSize) //r clrDepth, // [in] DWORD dwRecClrDepth, &flags); // [in, out] DWORD *pdwFlags if (FAILED(hr)) - return NULL; + return nullptr; } - HBITMAP bitmap = NULL; + HBITMAP bitmap = nullptr; { HRESULT hr = extractImage->Extract(&bitmap); if (FAILED(hr) || !bitmap) - return NULL; + return nullptr; } - ZEN_ON_BLOCK_EXIT(::DeleteObject(bitmap)); + ZEN_ON_SCOPE_EXIT(::DeleteObject(bitmap)); BITMAP bmpInfo = {}; if (::GetObject(bitmap, //__in HGDIOBJ hgdiobj, sizeof(bmpInfo), //__in int cbBuffer, &bmpInfo) == 0) //__out LPVOID lpvObject - return NULL; + return nullptr; - HBITMAP bitmapMask = ::CreateCompatibleBitmap(::GetDC(NULL), bmpInfo.bmWidth, bmpInfo.bmHeight); + HBITMAP bitmapMask = ::CreateCompatibleBitmap(::GetDC(nullptr), bmpInfo.bmWidth, bmpInfo.bmHeight); if (bitmapMask == 0) - return NULL; - ZEN_ON_BLOCK_EXIT(::DeleteObject(bitmapMask)); + return nullptr; + ZEN_ON_SCOPE_EXIT(::DeleteObject(bitmapMask)); ICONINFO iconInfo = {}; iconInfo.fIcon = true; @@ -141,7 +141,7 @@ thumb::HICON thumb::getIconByIndex(int iconIndex, int shilIconType) //return 0 o HRESULT hr = ::SHGetImageList(shilIconType, //__in int iImageList, IID_PPV_ARGS(imageList.init())); if (FAILED(hr) || !imageList) - return NULL; + return nullptr; } bool hasAlpha = false; //perf: 0,14 µs @@ -153,7 +153,7 @@ thumb::HICON thumb::getIconByIndex(int iconIndex, int shilIconType) //return 0 o hasAlpha = flags & ILIF_ALPHA; } - ::HICON hIcon = NULL; //perf: 1,5 ms - the dominant block + ::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, @@ -161,7 +161,7 @@ thumb::HICON thumb::getIconByIndex(int iconIndex, int shilIconType) //return 0 o //other flags: http://msdn.microsoft.com/en-us/library/windows/desktop/bb775230(v=vs.85).aspx &hIcon); // [out] HICON *picon if (FAILED(hr) || !hIcon) - return NULL; + return nullptr; } return hIcon; |