refactor: createThumbnailFromPath takes size not maxSize (#37796)

refactor: `createThumbnailFromPath` takes `size` not `maxSize` (#37362)

refactor: createThumbnailFromPath takes size not maxSize
This commit is contained in:
Keeley Hammond
2023-04-03 03:39:50 -07:00
committed by GitHub
parent ff01742f8e
commit 82869b88f1
5 changed files with 112 additions and 12 deletions

View File

@@ -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;
}