summaryrefslogtreecommitdiffstats
path: root/ui/gfx/icon_util.h
diff options
context:
space:
mode:
authorasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-14 19:45:34 +0000
committerasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-14 19:45:34 +0000
commitbe74fb58a37659c21a7e785589c383b688595be6 (patch)
tree5a9f41de2b3ed29c7ead47669de695e36011cab2 /ui/gfx/icon_util.h
parent6c70eeb6d75752cf322548f8b4b82324ab9456ba (diff)
downloadchromium_src-be74fb58a37659c21a7e785589c383b688595be6.zip
chromium_src-be74fb58a37659c21a7e785589c383b688595be6.tar.gz
chromium_src-be74fb58a37659c21a7e785589c383b688595be6.tar.bz2
Add support for getting the 256x256 app icon on Windows as a SkBitmap.
Also, adds an icon (a copy of chrome/app/theme/chromium/chromium.ico) to ui_unittests.exe, which is needed by the tests for this new functionality. The icon was landed here: https://codereview.chromium.org/11877018/ BUG=167277 TEST=New unit tests in icon_util_unittests.cc. Review URL: https://chromiumcodereview.appspot.com/11778073 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176700 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/icon_util.h')
-rw-r--r--ui/gfx/icon_util.h34
1 files changed, 33 insertions, 1 deletions
diff --git a/ui/gfx/icon_util.h b/ui/gfx/icon_util.h
index ae16e01..dfeea4c 100644
--- a/ui/gfx/icon_util.h
+++ b/ui/gfx/icon_util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,6 +11,7 @@
#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
+#include "base/memory/scoped_ptr.h"
#include "ui/base/ui_export.h"
#include "ui/gfx/point.h"
#include "ui/gfx/size.h"
@@ -73,6 +74,14 @@ class UI_EXPORT IconUtil {
// it when it is no longer needed.
static SkBitmap* CreateSkBitmapFromHICON(HICON icon, const gfx::Size& s);
+ // Loads an icon resource as a SkBitmap for the specified |size| from a
+ // loaded .dll or .exe |module|. Supports loading smaller icon sizes as well
+ // as the Vista+ 256x256 PNG icon size. If the icon could not be loaded or
+ // found, returns a NULL scoped_ptr.
+ static scoped_ptr<SkBitmap> CreateSkBitmapFromIconResource(HMODULE module,
+ int resource_id,
+ int size);
+
// Given a valid HICON handle representing an icon, this function converts
// the icon into an SkBitmap object containing an ARGB bitmap using the
// dimensions of HICON. If the function cannot convert the icon to a bitmap
@@ -109,6 +118,7 @@ class UI_EXPORT IconUtil {
// the icon file structures in any of the Windows header files so we need to
// define these structure within the class. We must make sure we use 2 byte
// packing so that the structures are layed out properly within the file.
+ // See: http://msdn.microsoft.com/en-us/library/ms997538.aspx
#pragma pack(push)
#pragma pack(2)
@@ -134,6 +144,28 @@ class UI_EXPORT IconUtil {
ICONDIRENTRY idEntries[1];
};
+ // GRPICONDIRENTRY contains meta data for an individual icon image within a
+ // RT_GROUP_ICON resource in an .exe or .dll.
+ struct GRPICONDIRENTRY {
+ BYTE bWidth;
+ BYTE bHeight;
+ BYTE bColorCount;
+ BYTE bReserved;
+ WORD wPlanes;
+ WORD wBitCount;
+ DWORD dwBytesInRes;
+ WORD nID;
+ };
+
+ // GRPICONDIR Contains information about all the icon images contained within
+ // a RT_GROUP_ICON resource in an .exe or .dll.
+ struct GRPICONDIR {
+ WORD idReserved;
+ WORD idType;
+ WORD idCount;
+ GRPICONDIRENTRY idEntries[1];
+ };
+
// Contains the actual icon image.
struct ICONIMAGE {
BITMAPINFOHEADER icHeader;