refactor: createThumbnailFromPath
takes size
not maxSize
(#37362)
refactor: createThumbnailFromPath takes size not maxSize
This commit is contained in:
parent
f33bf2a271
commit
8ee58e18fd
5 changed files with 72 additions and 12 deletions
|
@ -43,7 +43,7 @@ v8::Local<v8::Promise> NativeImage::CreateThumbnailFromPath(
|
|||
|
||||
if (FAILED(hr)) {
|
||||
promise.RejectWithErrorMessage(
|
||||
"failed to create IShellItem from the given path");
|
||||
"Failed to create IShellItem from the given path");
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
@ -53,21 +53,20 @@ v8::Local<v8::Promise> NativeImage::CreateThumbnailFromPath(
|
|||
IID_PPV_ARGS(&pThumbnailCache));
|
||||
if (FAILED(hr)) {
|
||||
promise.RejectWithErrorMessage(
|
||||
"failed to acquire local thumbnail cache reference");
|
||||
"Failed to acquire local thumbnail cache reference");
|
||||
return handle;
|
||||
}
|
||||
|
||||
// Populate the IShellBitmap
|
||||
Microsoft::WRL::ComPtr<ISharedBitmap> pThumbnail;
|
||||
WTS_CACHEFLAGS flags;
|
||||
WTS_THUMBNAILID thumbId;
|
||||
hr = pThumbnailCache->GetThumbnail(pItem.Get(), size.width(),
|
||||
WTS_FLAGS::WTS_NONE, &pThumbnail, &flags,
|
||||
&thumbId);
|
||||
hr = pThumbnailCache->GetThumbnail(
|
||||
pItem.Get(), size.width(),
|
||||
WTS_FLAGS::WTS_SCALETOREQUESTEDSIZE | WTS_FLAGS::WTS_SCALEUP, &pThumbnail,
|
||||
NULL, NULL);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
promise.RejectWithErrorMessage(
|
||||
"failed to get thumbnail from local thumbnail cache reference");
|
||||
"Failed to get thumbnail from local thumbnail cache reference");
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
@ -75,14 +74,14 @@ v8::Local<v8::Promise> NativeImage::CreateThumbnailFromPath(
|
|||
HBITMAP hBitmap = NULL;
|
||||
hr = pThumbnail->GetSharedBitmap(&hBitmap);
|
||||
if (FAILED(hr)) {
|
||||
promise.RejectWithErrorMessage("failed to extract bitmap from thumbnail");
|
||||
promise.RejectWithErrorMessage("Failed to extract bitmap from thumbnail");
|
||||
return handle;
|
||||
}
|
||||
|
||||
// convert HBITMAP to gfx::Image
|
||||
BITMAP bitmap;
|
||||
if (!GetObject(hBitmap, sizeof(bitmap), &bitmap)) {
|
||||
promise.RejectWithErrorMessage("could not convert HBITMAP to BITMAP");
|
||||
promise.RejectWithErrorMessage("Could not convert HBITMAP to BITMAP");
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue