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

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
« ui/gfx/color_analysis.h ('K') | « 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..08b1b8ed4cbca0f2ce318744dceded4ace4b1bb7 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,17 +398,22 @@ SkColor CalculateKMeanColorOfBitmap(const SkBitmap& bitmap) {
scoped_ptr<uint32_t[]> image(new uint32_t[pixel_count]);
UnPreMultiply(bitmap, image.get(), pixel_count);
- GridSampler sampler;
- SkColor color = CalculateKMeanColorOfBuffer(
- reinterpret_cast<uint8_t*>(image.get()),
- bitmap.width(),
- bitmap.height(),
- kMinDarkness,
- kMaxBrightness,
- &sampler);
+ SkColor color =
+ CalculateKMeanColorOfBuffer(reinterpret_cast<uint8_t*>(image.get()),
Alexei Svitkine (slow) 2014/05/26 18:20:49 Nit: Just return it directly.
calamity 2014/05/27 01:19:42 Done.
+ bitmap.width(),
+ bitmap.height(),
+ darkness_limit,
+ brightness_limit,
+ sampler);
return color;
}
+SkColor CalculateKMeanColorOfBitmap(const SkBitmap& bitmap) {
+ GridSampler sampler;
+ return CalculateKMeanColorOfBitmap(
+ bitmap, kMinDarkness, kMaxBrightness, &sampler);
+}
+
gfx::Matrix3F ComputeColorCovariance(const SkBitmap& bitmap) {
// First need basic stats to normalize each channel separately.
SkAutoLockPixels bitmap_lock(bitmap);
« ui/gfx/color_analysis.h ('K') | « ui/gfx/color_analysis.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698