OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/message_center/views/small_image_mask.h" | |
6 | |
7 #include "ui/gfx/image/image_skia_operations.h" | |
8 | |
9 // Take small_iamge as the alpha channel, mask it with the foreground, | |
10 // then add the masked foreground on top of the background | |
11 const gfx::ImageSkia GetMaskedSmallImage(const gfx::ImageSkia& small_image) { | |
dewittj
2014/06/16 18:09:55
I would just move this into notification_view.cc i
liyanhou
2014/06/27 03:18:40
Done.
| |
12 int width = small_image.width(); | |
13 int height = small_image.height(); | |
14 | |
15 // Background color grey | |
16 const gfx::ImageSkia background = CreateImage(width, height, 163, 163, 163); | |
dewittj
2014/06/16 18:09:55
I would suggest you use an SkColor in these functi
liyanhou
2014/06/27 03:18:40
Done.
| |
17 // Foreground color white | |
18 const gfx::ImageSkia foreground = CreateImage(width, height, 255, 255, 255); | |
19 const gfx::ImageSkia masked_small_image = | |
20 gfx::ImageSkiaOperations::CreateMaskedImage(foreground, small_image); | |
21 return gfx::ImageSkiaOperations::CreateSuperimposedImage(background, | |
22 masked_small_image); | |
23 } | |
24 | |
25 const gfx::ImageSkia CreateImage(int width, | |
26 int height, | |
27 int red, | |
28 int green, | |
29 int blue) { | |
30 return gfx::ImageSkia::CreateFrom1xBitmap( | |
31 CreateBitmap(width, height, red, green, blue)); | |
32 } | |
33 | |
34 const SkBitmap CreateBitmap(int width, | |
35 int height, | |
36 int red, | |
37 int green, | |
38 int blue) { | |
39 SkBitmap bitmap; | |
40 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); | |
41 bitmap.allocPixels(); | |
42 bitmap.eraseRGB(red, green, blue); | |
43 return bitmap; | |
44 } | |
OLD | NEW |