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

Unified Diff: ui/gfx/color_analysis.cc

Issue 291653004: Add extra overloads for color analysis. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nits Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/color_analysis.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/color_analysis.cc
diff --git a/ui/gfx/color_analysis.cc b/ui/gfx/color_analysis.cc
index 4c8bfa2007b33ef8ec3caf92c6f359305d315420..c243970da4fcb286de4aaa41ceee99bd81a296bf 100644
--- a/ui/gfx/color_analysis.cc
+++ b/ui/gfx/color_analysis.cc
@@ -382,7 +382,15 @@ SkColor CalculateKMeanColorOfPNG(scoped_refptr<base::RefCountedMemory> png,
return color;
}
-SkColor CalculateKMeanColorOfBitmap(const SkBitmap& bitmap) {
+SkColor CalculateKMeanColorOfPNG(scoped_refptr<base::RefCountedMemory> png) {
+ GridSampler sampler;
+ return CalculateKMeanColorOfPNG(png, kMinDarkness, kMaxBrightness, &sampler);
+}
+
+SkColor CalculateKMeanColorOfBitmap(const SkBitmap& bitmap,
+ uint32_t darkness_limit,
+ uint32_t brightness_limit,
+ KMeanImageSampler* sampler) {
// SkBitmap uses pre-multiplied alpha but the KMean clustering function
// above uses non-pre-multiplied alpha. Transform the bitmap before we
// analyze it because the function reads each pixel multiple times.
@@ -390,15 +398,18 @@ SkColor CalculateKMeanColorOfBitmap(const SkBitmap& bitmap) {
scoped_ptr<uint32_t[]> image(new uint32_t[pixel_count]);
UnPreMultiply(bitmap, image.get(), pixel_count);
+ return CalculateKMeanColorOfBuffer(reinterpret_cast<uint8_t*>(image.get()),
+ bitmap.width(),
+ bitmap.height(),
+ darkness_limit,
+ brightness_limit,
+ sampler);
+}
+
+SkColor CalculateKMeanColorOfBitmap(const SkBitmap& bitmap) {
GridSampler sampler;
- SkColor color = CalculateKMeanColorOfBuffer(
- reinterpret_cast<uint8_t*>(image.get()),
- bitmap.width(),
- bitmap.height(),
- kMinDarkness,
- kMaxBrightness,
- &sampler);
- return color;
+ return CalculateKMeanColorOfBitmap(
+ bitmap, kMinDarkness, kMaxBrightness, &sampler);
}
gfx::Matrix3F ComputeColorCovariance(const SkBitmap& bitmap) {
« no previous file with comments | « ui/gfx/color_analysis.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698