OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/profiles/profile_info_util.h" | 5 #include "chrome/browser/profiles/profile_info_util.h" |
6 | 6 |
7 #include "skia/ext/image_operations.h" | 7 #include "skia/ext/image_operations.h" |
8 #include "ui/gfx/canvas_skia.h" | 8 #include "ui/gfx/canvas_skia.h" |
9 #include "ui/gfx/rect.h" | 9 #include "ui/gfx/rect.h" |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 int y = (kAvatarIconHeight - length) / 2; | 28 int y = (kAvatarIconHeight - length) / 2; |
29 canvas.DrawBitmapInt(bmp, x, y); | 29 canvas.DrawBitmapInt(bmp, x, y); |
30 | 30 |
31 // Draw a gray border on the inside of the icon. | 31 // Draw a gray border on the inside of the icon. |
32 SkColor color = SkColorSetARGB(83, 0, 0, 0); | 32 SkColor color = SkColorSetARGB(83, 0, 0, 0); |
33 canvas.DrawRectInt(color, x, y, length - 1, length - 1); | 33 canvas.DrawRectInt(color, x, y, length - 1, length - 1); |
34 | 34 |
35 return gfx::Image(new SkBitmap(canvas.ExtractBitmap())); | 35 return gfx::Image(new SkBitmap(canvas.ExtractBitmap())); |
36 } | 36 } |
37 | 37 |
| 38 gfx::Image GetAvatarIconForWebUI(const gfx::Image& image, |
| 39 bool is_gaia_picture) { |
| 40 if (!is_gaia_picture) |
| 41 return image; |
| 42 |
| 43 int length = std::min(kAvatarIconWidth, kAvatarIconHeight) - 2; |
| 44 SkBitmap bmp = skia::ImageOperations::Resize( |
| 45 image, skia::ImageOperations::RESIZE_BEST, length, length); |
| 46 gfx::CanvasSkia canvas(kAvatarIconWidth, kAvatarIconHeight, false); |
| 47 |
| 48 // Draw the icon centered on the canvas. |
| 49 int x = (kAvatarIconWidth - length) / 2; |
| 50 int y = (kAvatarIconHeight - length) / 2; |
| 51 canvas.DrawBitmapInt(bmp, x, y); |
| 52 |
| 53 return gfx::Image(new SkBitmap(canvas.ExtractBitmap())); |
| 54 } |
| 55 |
38 gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image, | 56 gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image, |
39 bool is_gaia_picture, | 57 bool is_gaia_picture, |
40 int dst_width, | 58 int dst_width, |
41 int dst_height) { | 59 int dst_height) { |
42 if (!is_gaia_picture) | 60 if (!is_gaia_picture) |
43 return image; | 61 return image; |
44 | 62 |
45 int length = std::min(std::min(kAvatarIconWidth, kAvatarIconHeight), | 63 int length = std::min(std::min(kAvatarIconWidth, kAvatarIconHeight), |
46 std::min(dst_width, dst_height)) - 2; | 64 std::min(dst_width, dst_height)) - 2; |
47 SkBitmap bmp = skia::ImageOperations::Resize( | 65 SkBitmap bmp = skia::ImageOperations::Resize( |
(...skipping 17 matching lines...) Expand all Loading... |
65 canvas.DrawLineInt(shadow_color, x1, y1, x2, y1); | 83 canvas.DrawLineInt(shadow_color, x1, y1, x2, y1); |
66 // Left shadow. | 84 // Left shadow. |
67 canvas.DrawLineInt(shadow_color, x1, y1 + 1, x1, y2 - 1); | 85 canvas.DrawLineInt(shadow_color, x1, y1 + 1, x1, y2 - 1); |
68 // Right shadow. | 86 // Right shadow. |
69 canvas.DrawLineInt(shadow_color, x2 - 1, y1 + 1, x2 - 1, y2 - 1); | 87 canvas.DrawLineInt(shadow_color, x2 - 1, y1 + 1, x2 - 1, y2 - 1); |
70 | 88 |
71 return gfx::Image(new SkBitmap(canvas.ExtractBitmap())); | 89 return gfx::Image(new SkBitmap(canvas.ExtractBitmap())); |
72 } | 90 } |
73 | 91 |
74 } // namespace | 92 } // namespace |
OLD | NEW |