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

Side by Side Diff: ui/gfx/color_utils.h

Issue 12335009: Implementation of principal-component color reduction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed (some) remarks from the review. Created 7 years, 10 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/gfx/color_utils.cc » ('j') | ui/gfx/color_utils.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 |scale_result|, result is linearly scalled to fit 0-0xFF range. Otherwise,
Alexei Svitkine (slow) 2013/02/21 19:49:33 Nit: scalled -> scaled
motek. 2013/02/21 22:45:03 Done.
86 // data is clipped to fit the range.
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 scale_result,
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_
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/color_utils.cc » ('j') | ui/gfx/color_utils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698