mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
refactor: createThumbnailFromPath takes size not maxSize (#37362)
refactor: createThumbnailFromPath takes size not maxSize
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user