refactor: createThumbnailFromPath takes size not maxSize (#37362)

refactor: createThumbnailFromPath takes size not maxSize
This commit is contained in:
Shelley Vohr 2023-03-09 03:48:29 +01:00 committed by GitHub
parent f33bf2a271
commit 8ee58e18fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 72 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;
}