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_COLOR_UTILS_H_ | 5 #ifndef UI_GFX_COLOR_UTILS_H_ |
6 #define UI_GFX_COLOR_UTILS_H_ | 6 #define UI_GFX_COLOR_UTILS_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
10 #include "ui/base/ui_export.h" | 10 #include "ui/base/ui_export.h" |
| 11 #include "ui/gfx/rect.h" |
| 12 #include "ui/gfx/vector3d_f.h" |
11 | 13 |
12 class SkBitmap; | 14 class SkBitmap; |
13 | 15 |
14 namespace color_utils { | 16 namespace color_utils { |
15 | 17 |
16 // Represents an HSL color. | 18 // Represents an HSL color. |
17 struct HSL { | 19 struct HSL { |
18 double h; | 20 double h; |
19 double s; | 21 double s; |
20 double l; | 22 double l; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // NOTE: This won't do anything but waste time if the supplied foreground color | 72 // NOTE: This won't do anything but waste time if the supplied foreground color |
71 // has a luma value close to the midpoint (0.5 in the HSL representation). | 73 // has a luma value close to the midpoint (0.5 in the HSL representation). |
72 UI_EXPORT SkColor GetReadableColor(SkColor foreground, SkColor background); | 74 UI_EXPORT SkColor GetReadableColor(SkColor foreground, SkColor background); |
73 | 75 |
74 // Invert a color. | 76 // Invert a color. |
75 UI_EXPORT SkColor InvertColor(SkColor color); | 77 UI_EXPORT SkColor InvertColor(SkColor color); |
76 | 78 |
77 // Gets a Windows system color as a SkColor | 79 // Gets a Windows system color as a SkColor |
78 UI_EXPORT SkColor GetSysSkColor(int which); | 80 UI_EXPORT SkColor GetSysSkColor(int which); |
79 | 81 |
| 82 // Apply a color reduction transform defined by |color_transform| vector to |
| 83 // |source_bitmap|. The result is put into |target_bitmap|, which is expected |
| 84 // to be initialized to the required size and type (SkBitmap::kA8_Config). |
| 85 // If |fit_to_range|, result is transfored linearly to fit 0-0xFF range. |
| 86 // Otherwise, data is clipped. |
| 87 // Returns true if the target has been computed. |
| 88 UI_EXPORT bool ApplyColorReduction(const SkBitmap& source_bitmap, |
| 89 const gfx::Vector3dF& color_transform, |
| 90 bool fit_to_range, |
| 91 SkBitmap* target_bitmap); |
| 92 |
| 93 // Compute a monochrome image representing the principal color component of |
| 94 // the |source_bitmap|. The result is stored in |target_bitmap|, which must be |
| 95 // initialized to the required size and type (SkBitmap::kA8_Config). |
| 96 // Returns true if the conversion succeeded. Note that there might be legitimate |
| 97 // reasons for the process to fail even if all input was correct. This is a |
| 98 // condition the caller must be able to handle. |
| 99 UI_EXPORT bool ComputePrincipalComponentImage(const SkBitmap& source_bitmap, |
| 100 SkBitmap* target_bitmap); |
| 101 |
80 } // namespace color_utils | 102 } // namespace color_utils |
81 | 103 |
82 #endif // UI_GFX_COLOR_UTILS_H_ | 104 #endif // UI_GFX_COLOR_UTILS_H_ |
OLD | NEW |