Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1979)

Unified Diff: chrome/browser/ui/views/create_application_shortcut_view.cc

Issue 1424913007: Added ImageFamily::CreateExact, which scales the best image to size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master-plus
Patch Set: IconUtil: Rewrite comment. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/icon_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/create_application_shortcut_view.cc
diff --git a/chrome/browser/ui/views/create_application_shortcut_view.cc b/chrome/browser/ui/views/create_application_shortcut_view.cc
index 972486934603e996dadb62d435d5d3d8c4c3f54d..3152d0be26a61ae0902622e93b221381467cd7a4 100644
--- a/chrome/browser/ui/views/create_application_shortcut_view.cc
+++ b/chrome/browser/ui/views/create_application_shortcut_view.cc
@@ -176,24 +176,11 @@ void AppInfoView::UpdateText(const base::string16& title,
}
void AppInfoView::UpdateIcon(const gfx::ImageFamily& image) {
- // Get the icon closest to the desired preview size.
- const gfx::Image* icon = image.GetBest(kIconPreviewSizePixels,
- kIconPreviewSizePixels);
- if (!icon || icon->IsEmpty())
- // The family has no icons. Leave the image blank.
- return;
- const SkBitmap& bitmap = *icon->ToSkBitmap();
- if (bitmap.width() == kIconPreviewSizePixels &&
- bitmap.height() == kIconPreviewSizePixels) {
- icon_->SetImage(gfx::ImageSkia::CreateFrom1xBitmap(bitmap));
- } else {
- // Resize the image to the desired size.
- SkBitmap resized_bitmap = skia::ImageOperations::Resize(
- bitmap, skia::ImageOperations::RESIZE_LANCZOS3,
- kIconPreviewSizePixels, kIconPreviewSizePixels);
-
- icon_->SetImage(gfx::ImageSkia::CreateFrom1xBitmap(resized_bitmap));
- }
+ // Get an icon at the desired preview size (scaling from a larger image if
+ // none is available at that exact size).
+ gfx::Image icon =
+ image.CreateExact(kIconPreviewSizePixels, kIconPreviewSizePixels);
+ icon_->SetImage(icon.ToImageSkia());
}
void AppInfoView::OnPaint(gfx::Canvas* canvas) {
« no previous file with comments | « no previous file | ui/gfx/icon_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698