diff options
author | lpromero <lpromero@chromium.org> | 2015-01-23 12:17:36 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-23 20:18:40 +0000 |
commit | a110f52e83cebd2b6f0ed37c34abeac8bfcb1b72 (patch) | |
tree | b0054fe1a2bbb25a9532fb7a1b9a1decb5b62a6d /components/enhanced_bookmarks/image_store_util.cc | |
parent | 921392d21263c05b374d94ae3da3120094cd6a65 (diff) | |
download | chromium_src-a110f52e83cebd2b6f0ed37c34abeac8bfcb1b72.zip chromium_src-a110f52e83cebd2b6f0ed37c34abeac8bfcb1b72.tar.gz chromium_src-a110f52e83cebd2b6f0ed37c34abeac8bfcb1b72.tar.bz2 |
★ Record the image dominant color in the image database.
This CL adds a column in the bookmarks images database.
It contains the dominant color extracted from the image.
Since this computation can be lengthy, it is done in the background, when the
image is stored in the database.
For old databases, a migration path is provided and the dominant color is
computed and stored upon querying the image for the first time.
BUG=448443
Review URL: https://codereview.chromium.org/875463003
Cr-Commit-Position: refs/heads/master@{#312916}
Diffstat (limited to 'components/enhanced_bookmarks/image_store_util.cc')
-rw-r--r-- | components/enhanced_bookmarks/image_store_util.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/components/enhanced_bookmarks/image_store_util.cc b/components/enhanced_bookmarks/image_store_util.cc index 213b595..ef3979d 100644 --- a/components/enhanced_bookmarks/image_store_util.cc +++ b/components/enhanced_bookmarks/image_store_util.cc @@ -4,6 +4,8 @@ #include "components/enhanced_bookmarks/image_store_util.h" +#include "third_party/skia/include/core/SkBitmap.h" +#include "ui/gfx/color_analysis.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_util.h" @@ -30,4 +32,8 @@ scoped_refptr<base::RefCountedMemory> BytesForImage(const gfx::Image& image) { gfx::Image ImageForBytes(const scoped_refptr<base::RefCountedMemory>& bytes) { return gfx::ImageFrom1xJPEGEncodedData(bytes->front(), bytes->size()); } + +SkColor DominantColorForImage(const gfx::Image& image) { + return color_utils::CalculateKMeanColorOfBitmap(*image.ToSkBitmap()); +} } |