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

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

Issue 2943333003: Extracting more than one wallpaper prominent color (Closed)
Patch Set: possible uninitialized local value Created 3 years, 6 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
« no previous file with comments | « tools/metrics/histograms/histograms.xml ('k') | ui/gfx/color_analysis.cc » ('j') | no next file with comments »
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_ANALYSIS_H_ 5 #ifndef UI_GFX_COLOR_ANALYSIS_H_
6 #define UI_GFX_COLOR_ANALYSIS_H_ 6 #define UI_GFX_COLOR_ANALYSIS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 LIGHT, 116 LIGHT,
117 NORMAL, 117 NORMAL,
118 DARK, 118 DARK,
119 }; 119 };
120 120
121 enum class SaturationRange { 121 enum class SaturationRange {
122 VIBRANT, 122 VIBRANT,
123 MUTED, 123 MUTED,
124 }; 124 };
125 125
126 // Returns a single RGB color that represents the bitmap. If a value is 126 struct ColorProfile {
127 // succesfully calculated, the return value is fully opaque. For failure, the 127 ColorProfile() = default;
128 // return value is transparent. This currently calculates one color at a time. 128 ColorProfile(LumaRange l, SaturationRange s) : luma(l), saturation(s) {}
129 // We could save computation by calculating multiple colors at once, but there's 129
130 // currently no need to calculate multiple colors. 130 LumaRange luma = LumaRange::DARK;
131 GFX_EXPORT SkColor CalculateProminentColorOfBitmap(const SkBitmap& bitmap, 131 SaturationRange saturation = SaturationRange::MUTED;
132 LumaRange luma, 132 };
133 SaturationRange saturation); 133
134 // Returns a vector of RGB colors that represents the bitmap based on the
135 // |color_profiles| provided. For each value, if a value is succesfully
136 // calculated, the calculated value is fully opaque. For failure, the calculated
137 // value is transparent.
138 GFX_EXPORT std::vector<SkColor> CalculateProminentColorsOfBitmap(
139 const SkBitmap& bitmap,
140 const std::vector<ColorProfile>& color_profiles);
134 141
135 // Compute color covariance matrix for the input bitmap. 142 // Compute color covariance matrix for the input bitmap.
136 GFX_EXPORT gfx::Matrix3F ComputeColorCovariance(const SkBitmap& bitmap); 143 GFX_EXPORT gfx::Matrix3F ComputeColorCovariance(const SkBitmap& bitmap);
137 144
138 // Apply a color reduction transform defined by |color_transform| vector to 145 // Apply a color reduction transform defined by |color_transform| vector to
139 // |source_bitmap|. The result is put into |target_bitmap|, which is expected 146 // |source_bitmap|. The result is put into |target_bitmap|, which is expected
140 // to be initialized to the required size and type (SkBitmap::kA8_Config). 147 // to be initialized to the required size and type (SkBitmap::kA8_Config).
141 // If |fit_to_range|, result is transfored linearly to fit 0-0xFF range. 148 // If |fit_to_range|, result is transfored linearly to fit 0-0xFF range.
142 // Otherwise, data is clipped. 149 // Otherwise, data is clipped.
143 // Returns true if the target has been computed. 150 // Returns true if the target has been computed.
144 GFX_EXPORT bool ApplyColorReduction(const SkBitmap& source_bitmap, 151 GFX_EXPORT bool ApplyColorReduction(const SkBitmap& source_bitmap,
145 const gfx::Vector3dF& color_transform, 152 const gfx::Vector3dF& color_transform,
146 bool fit_to_range, 153 bool fit_to_range,
147 SkBitmap* target_bitmap); 154 SkBitmap* target_bitmap);
148 155
149 // Compute a monochrome image representing the principal color component of 156 // Compute a monochrome image representing the principal color component of
150 // the |source_bitmap|. The result is stored in |target_bitmap|, which must be 157 // the |source_bitmap|. The result is stored in |target_bitmap|, which must be
151 // initialized to the required size and type (SkBitmap::kA8_Config). 158 // initialized to the required size and type (SkBitmap::kA8_Config).
152 // Returns true if the conversion succeeded. Note that there might be legitimate 159 // Returns true if the conversion succeeded. Note that there might be legitimate
153 // reasons for the process to fail even if all input was correct. This is a 160 // reasons for the process to fail even if all input was correct. This is a
154 // condition the caller must be able to handle. 161 // condition the caller must be able to handle.
155 GFX_EXPORT bool ComputePrincipalComponentImage(const SkBitmap& source_bitmap, 162 GFX_EXPORT bool ComputePrincipalComponentImage(const SkBitmap& source_bitmap,
156 SkBitmap* target_bitmap); 163 SkBitmap* target_bitmap);
157 164
158 } // namespace color_utils 165 } // namespace color_utils
159 166
160 #endif // UI_GFX_COLOR_ANALYSIS_H_ 167 #endif // UI_GFX_COLOR_ANALYSIS_H_
OLDNEW
« no previous file with comments | « tools/metrics/histograms/histograms.xml ('k') | ui/gfx/color_analysis.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698