OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 GFX_ICON_UTIL_H_ | 5 #ifndef GFX_ICON_UTIL_H_ |
6 #define GFX_ICON_UTIL_H_ | 6 #define GFX_ICON_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <windows.h> | 9 #include <windows.h> |
10 #include <string> | 10 #include <string> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // ::SendMessage(hwnd, WM_SETICON, static_cast<WPARAM>(ICON_BIG), | 44 // ::SendMessage(hwnd, WM_SETICON, static_cast<WPARAM>(ICON_BIG), |
45 // reinterpret_cast<LPARAM>(icon)); | 45 // reinterpret_cast<LPARAM>(icon)); |
46 // | 46 // |
47 // // Destroy the icon when we are done | 47 // // Destroy the icon when we are done |
48 // ::DestroyIcon(icon); | 48 // ::DestroyIcon(icon); |
49 // | 49 // |
50 /////////////////////////////////////////////////////////////////////////////// | 50 /////////////////////////////////////////////////////////////////////////////// |
51 class IconUtil { | 51 class IconUtil { |
52 public: | 52 public: |
53 // Given an SkBitmap object, the function converts the bitmap to a Windows | 53 // Given an SkBitmap object, the function converts the bitmap to a Windows |
54 // icon and returns the corresponding HICON handle. If the function can not | 54 // icon and returns the corresponding HICON handle. If the function cannot |
55 // convert the bitmap, NULL is returned. | 55 // convert the bitmap, NULL is returned. |
56 // | 56 // |
57 // The client is responsible for destroying the icon when it is no longer | 57 // The client is responsible for destroying the icon when it is no longer |
58 // needed by calling ::DestroyIcon(). | 58 // needed by calling ::DestroyIcon(). |
59 static HICON CreateHICONFromSkBitmap(const SkBitmap& bitmap); | 59 static HICON CreateHICONFromSkBitmap(const SkBitmap& bitmap); |
60 | 60 |
61 // Given a valid HICON handle representing an icon, this function converts | 61 // Given a valid HICON handle representing an icon, this function converts |
62 // the icon into an SkBitmap object containing an ARGB bitmap using the | 62 // the icon into an SkBitmap object containing an ARGB bitmap using the |
63 // dimensions specified in |s|. |s| must specify valid dimensions (both | 63 // dimensions specified in |s|. |s| must specify valid dimensions (both |
64 // width() an height() must be greater than zero). If the function can | 64 // width() an height() must be greater than zero). If the function cannot |
65 // convert the icon to a bitmap (most probably due to an invalid parameter), | 65 // convert the icon to a bitmap (most probably due to an invalid parameter), |
66 // the return value is NULL. | 66 // the return value is NULL. |
67 // | 67 // |
68 // The client owns the returned bitmap object and is responsible for deleting | 68 // The client owns the returned bitmap object and is responsible for deleting |
69 // it when it is no longer needed. | 69 // it when it is no longer needed. |
70 static SkBitmap* CreateSkBitmapFromHICON(HICON icon, const gfx::Size& s); | 70 static SkBitmap* CreateSkBitmapFromHICON(HICON icon, const gfx::Size& s); |
71 | 71 |
72 // Given an initialized SkBitmap object and a file name, this function | 72 // Given an initialized SkBitmap object and a file name, this function |
73 // creates a .ico file with the given name using the provided bitmap. The | 73 // creates a .ico file with the given name using the provided bitmap. The |
74 // icon file is created with multiple icon images of varying predefined | 74 // icon file is created with multiple icon images of varying predefined |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 static void ComputeBitmapSizeComponents(const SkBitmap& bitmap, | 185 static void ComputeBitmapSizeComponents(const SkBitmap& bitmap, |
186 size_t* xor_mask_size, | 186 size_t* xor_mask_size, |
187 size_t* bytes_in_resource); | 187 size_t* bytes_in_resource); |
188 | 188 |
189 // Prevent clients from instantiating objects of that class by declaring the | 189 // Prevent clients from instantiating objects of that class by declaring the |
190 // ctor/dtor as private. | 190 // ctor/dtor as private. |
191 DISALLOW_IMPLICIT_CONSTRUCTORS(IconUtil); | 191 DISALLOW_IMPLICIT_CONSTRUCTORS(IconUtil); |
192 }; | 192 }; |
193 | 193 |
194 #endif // GFX_ICON_UTIL_H_ | 194 #endif // GFX_ICON_UTIL_H_ |
OLD | NEW |