OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GFX_ICON_UTIL_H_ | 5 #ifndef UI_GFX_ICON_UTIL_H_ |
6 #define UI_GFX_ICON_UTIL_H_ | 6 #define UI_GFX_ICON_UTIL_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "ui/base/ui_export.h" | 15 #include "ui/base/ui_export.h" |
16 #include "ui/gfx/point.h" | 16 #include "ui/gfx/point.h" |
17 #include "ui/gfx/size.h" | 17 #include "ui/gfx/size.h" |
18 | 18 |
| 19 namespace base { |
| 20 class FilePath; |
| 21 } |
| 22 |
19 namespace gfx { | 23 namespace gfx { |
20 class Size; | 24 class Size; |
21 } | 25 } |
22 class FilePath; | |
23 class SkBitmap; | 26 class SkBitmap; |
24 | 27 |
25 /////////////////////////////////////////////////////////////////////////////// | 28 /////////////////////////////////////////////////////////////////////////////// |
26 // | 29 // |
27 // The IconUtil class contains helper functions for manipulating Windows icons. | 30 // The IconUtil class contains helper functions for manipulating Windows icons. |
28 // The class interface contains methods for converting an HICON handle into an | 31 // The class interface contains methods for converting an HICON handle into an |
29 // SkBitmap object and vice versa. The class can also create a .ico file given | 32 // SkBitmap object and vice versa. The class can also create a .ico file given |
30 // a PNG image contained in an SkBitmap object. The following code snippet | 33 // a PNG image contained in an SkBitmap object. The following code snippet |
31 // shows an example usage of IconUtil::CreateHICONFromSkBitmap(): | 34 // shows an example usage of IconUtil::CreateHICONFromSkBitmap(): |
32 // | 35 // |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // depending on where the icon is drawn (ALT+TAB window, desktop shortcut, | 103 // depending on where the icon is drawn (ALT+TAB window, desktop shortcut, |
101 // Quick Launch, etc.). | 104 // Quick Launch, etc.). |
102 // | 105 // |
103 // To create an icon file containing a 256x256 PNG entry, which is used by | 106 // To create an icon file containing a 256x256 PNG entry, which is used by |
104 // Vista+ for high res icons, specify a non-empty 256x256 SkBitmap for the | 107 // Vista+ for high res icons, specify a non-empty 256x256 SkBitmap for the |
105 // |large_bitmap| parameter. | 108 // |large_bitmap| parameter. |
106 // | 109 // |
107 // The function returns true on success and false otherwise. | 110 // The function returns true on success and false otherwise. |
108 static bool CreateIconFileFromSkBitmap(const SkBitmap& bitmap, | 111 static bool CreateIconFileFromSkBitmap(const SkBitmap& bitmap, |
109 const SkBitmap& large_bitmap, | 112 const SkBitmap& large_bitmap, |
110 const FilePath& icon_path); | 113 const base::FilePath& icon_path); |
111 | 114 |
112 // Creates a cursor of the specified size from the DIB passed in. | 115 // Creates a cursor of the specified size from the DIB passed in. |
113 // Returns the cursor on success or NULL on failure. | 116 // Returns the cursor on success or NULL on failure. |
114 static HICON CreateCursorFromDIB(const gfx::Size& icon_size, | 117 static HICON CreateCursorFromDIB(const gfx::Size& icon_size, |
115 const gfx::Point& hotspot, | 118 const gfx::Point& hotspot, |
116 const void* dib_bits, | 119 const void* dib_bits, |
117 size_t dib_size); | 120 size_t dib_size); |
118 | 121 |
119 private: | 122 private: |
120 // The icon format is published in the MSDN but there is no definition of | 123 // The icon format is published in the MSDN but there is no definition of |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 // A helper function of CreateSkBitmapFromHICON. | 252 // A helper function of CreateSkBitmapFromHICON. |
250 static SkBitmap CreateSkBitmapFromHICONHelper(HICON icon, | 253 static SkBitmap CreateSkBitmapFromHICONHelper(HICON icon, |
251 const gfx::Size& s); | 254 const gfx::Size& s); |
252 | 255 |
253 // Prevent clients from instantiating objects of that class by declaring the | 256 // Prevent clients from instantiating objects of that class by declaring the |
254 // ctor/dtor as private. | 257 // ctor/dtor as private. |
255 DISALLOW_IMPLICIT_CONSTRUCTORS(IconUtil); | 258 DISALLOW_IMPLICIT_CONSTRUCTORS(IconUtil); |
256 }; | 259 }; |
257 | 260 |
258 #endif // UI_GFX_ICON_UTIL_H_ | 261 #endif // UI_GFX_ICON_UTIL_H_ |
OLD | NEW |