OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import <UIKit/UIKit.h> | 5 #import <UIKit/UIKit.h> |
6 | 6 |
7 #import "ios/chrome/browser/ui/image_util.h" | 7 #import "ios/chrome/browser/ui/image_util.h" |
8 | 8 |
9 #include "ui/gfx/color_analysis.h" | 9 #include "ui/gfx/color_analysis.h" |
10 #include "ui/gfx/image/image.h" | 10 #include "ui/gfx/image/image.h" |
11 | 11 |
12 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
13 #error "This file requires ARC support." | |
14 #endif | |
15 | |
16 UIColor* DominantColorForImage(const gfx::Image& image, CGFloat opacity) { | 12 UIColor* DominantColorForImage(const gfx::Image& image, CGFloat opacity) { |
17 SkColor color = color_utils::CalculateKMeanColorOfBitmap(*image.ToSkBitmap()); | 13 SkColor color = color_utils::CalculateKMeanColorOfBitmap(*image.ToSkBitmap()); |
18 UIColor* result = [UIColor colorWithRed:SkColorGetR(color) / 255.0 | 14 UIColor* result = [UIColor colorWithRed:SkColorGetR(color) / 255.0 |
19 green:SkColorGetG(color) / 255.0 | 15 green:SkColorGetG(color) / 255.0 |
20 blue:SkColorGetB(color) / 255.0 | 16 blue:SkColorGetB(color) / 255.0 |
21 alpha:opacity]; | 17 alpha:opacity]; |
22 return result; | 18 return result; |
23 } | 19 } |
24 | 20 |
25 UIImage* StretchableImageFromUIImage(UIImage* image, | 21 UIImage* StretchableImageFromUIImage(UIImage* image, |
(...skipping 17 matching lines...) Expand all Loading... |
43 | 39 |
44 UIImage* StretchableImageNamed(NSString* name, | 40 UIImage* StretchableImageNamed(NSString* name, |
45 NSInteger left_cap_width, | 41 NSInteger left_cap_width, |
46 NSInteger top_cap_height) { | 42 NSInteger top_cap_height) { |
47 UIImage* image = [UIImage imageNamed:name]; | 43 UIImage* image = [UIImage imageNamed:name]; |
48 if (!image) | 44 if (!image) |
49 return nil; | 45 return nil; |
50 | 46 |
51 return StretchableImageFromUIImage(image, left_cap_width, top_cap_height); | 47 return StretchableImageFromUIImage(image, left_cap_width, top_cap_height); |
52 } | 48 } |
OLD | NEW |