summaryrefslogtreecommitdiff
path: root/lib/Thumbnail
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Thumbnail')
-rw-r--r--lib/Thumbnail/thumbnail.cpp66
-rw-r--r--lib/Thumbnail/thumbnail.h4
2 files changed, 35 insertions, 35 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;
diff --git a/lib/Thumbnail/thumbnail.h b/lib/Thumbnail/thumbnail.h
index 7e11812c..b8b95d8f 100644
--- a/lib/Thumbnail/thumbnail.h
+++ b/lib/Thumbnail/thumbnail.h
@@ -21,8 +21,8 @@ namespace thumb
/*
PREREQUISITES:
-1. COM must be initialized for the current thread via ::CoInitialize(NULL) or ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED),
- but NOT ::CoInitializeEx(NULL, COINIT_MULTITHREADED) -> internal access violation crash!
+1. COM must be initialized for the current thread via ::CoInitialize(nullptr) or ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED),
+ but NOT ::CoInitializeEx(nullptr, COINIT_MULTITHREADED) -> internal access violation crash!
2. call ::FileIconInit() on app start to remedy obscure errors like SHELL_E_WRONG_BITDEPTH (0x80270102)
for certain file types, e.g. lnk, mpg - required on Windows 7 see http://msdn.microsoft.com/en-us/library/ms683212(v=VS.85).aspx
*/
bgstack15