OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef UI_GFX_IMAGESKIA_OPERATIONS_H_ | 5 #ifndef UI_GFX_IMAGESKIA_OPERATIONS_H_ |
6 #define UI_GFX_IMAGESKIA_OPERATIONS_H_ | 6 #define UI_GFX_IMAGESKIA_OPERATIONS_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "ui/base/ui_export.h" | 9 #include "ui/base/ui_export.h" |
10 #include "ui/gfx/size.h" | 10 #include "ui/gfx/color_utils.h" |
11 | 11 |
12 namespace gfx { | 12 namespace gfx { |
13 class ImageSkia; | 13 class ImageSkia; |
14 class Rect; | |
15 class Size; | |
14 | 16 |
15 class UI_EXPORT ImageSkiaOperations { | 17 class UI_EXPORT ImageSkiaOperations { |
16 public: | 18 public: |
17 // Create an image that is a blend of two others. The alpha argument | 19 // Create an image that is a blend of two others. The alpha argument |
18 // specifies the opacity of the second imag. The provided image must | 20 // specifies the opacity of the second imag. The provided image must |
19 // use the kARGB_8888_Config config and be of equal dimensions. | 21 // use the kARGB_8888_Config config and be of equal dimensions. |
20 static ImageSkia CreateBlendedImage(const ImageSkia& first, | 22 static ImageSkia CreateBlendedImage(const ImageSkia& first, |
21 const ImageSkia& second, | 23 const ImageSkia& second, |
22 double alpha); | 24 double alpha); |
23 | 25 |
24 // Create an image that is the original image masked out by the mask defined | 26 // Create an image that is the original image masked out by the mask defined |
25 // in the alpha image. The images must use the kARGB_8888_Config config and | 27 // in the alpha image. The images must use the kARGB_8888_Config config and |
26 // be of equal dimensions. | 28 // be of equal dimensions. |
27 static ImageSkia CreateMaskedImage(const ImageSkia& first, | 29 static ImageSkia CreateMaskedImage(const ImageSkia& first, |
28 const ImageSkia& alpha); | 30 const ImageSkia& alpha); |
29 | 31 |
30 // Create an image that is cropped from another image. This is special | 32 // Create an image that is cropped from another image. This is special |
31 // because it tiles the original image, so your coordinates can extend | 33 // because it tiles the original image, so your coordinates can extend |
32 // outside the bounds of the original image. | 34 // outside the bounds of the original image. |
33 static ImageSkia CreateTiledImage(const ImageSkia& image, | 35 static ImageSkia CreateTiledImage(const ImageSkia& image, |
34 int src_x, int src_y, | 36 int src_x, int src_y, |
35 int dst_w, int dst_h); | 37 int dst_w, int dst_h); |
36 | 38 |
39 // We create a button background image by compositing the color and image | |
40 // together, then applying the mask. This is a highly specialized composite | |
41 // operation that is the equivalent of drawing a background in |color|, | |
42 // tiling |image| over the top, and then masking the result out with |mask|. | |
43 // The images must use kARGB_8888_Config config. | |
44 static ImageSkia CreateButtonBackground(SkColor color, | |
oshima
2012/07/13 16:54:55
If this is specific to image button, i'd keep it i
pkotwicz
2012/07/15 03:36:48
I want to keep it here if only because this method
| |
45 const gfx::ImageSkia& image, | |
46 const gfx::ImageSkia& mask); | |
47 | |
48 // Shift an image's HSL values. The shift values are in the range of 0-1, | |
49 // with the option to specify -1 for 'no change'. The shift values are | |
50 // defined as: | |
51 // hsl_shift[0] (hue): The absolute hue value for the image - 0 and 1 map | |
52 // to 0 and 360 on the hue color wheel (red). | |
53 // hsl_shift[1] (saturation): A saturation shift for the image, with the | |
54 // following key values: | |
55 // 0 = remove all color. | |
56 // 0.5 = leave unchanged. | |
57 // 1 = fully saturate the image. | |
58 // hsl_shift[2] (lightness): A lightness shift for the image, with the | |
59 // following key values: | |
60 // 0 = remove all lightness (make all pixels black). | |
61 // 0.5 = leave unchanged. | |
62 // 1 = full lightness (make all pixels white). | |
63 static ImageSkia CreateHSLShiftedImage(const gfx::ImageSkia& image, | |
64 const color_utils::HSL& hsl_shift); | |
65 | |
66 // Create an image by combining alpha channel of |image| and color |c|. | |
67 // The image must use the kARGB_8888_Config config. | |
68 static ImageSkia CreateColorMask(const gfx::ImageSkia& image, SkColor c); | |
oshima
2012/07/13 16:54:55
Are these used in this CL? I prefer to add when yo
| |
69 | |
70 // Returns an image which is a subset of |image| with bounds |subset_bounds|. | |
71 static ImageSkia ExtractSubset(const gfx::ImageSkia& image, | |
72 const gfx::Rect& subset_bounds); | |
73 | |
37 // Creates an image that resizes |source| to given |target_size_in_dip|. | 74 // Creates an image that resizes |source| to given |target_size_in_dip|. |
38 // The resize operation occurs synchronously at the time that the desired | 75 // The resize operation occurs synchronously at the time that the desired |
39 // scale factor is known (either GetRepresentation is called or the image | 76 // scale factor is known (either GetRepresentation is called or the image |
40 // is painted). | 77 // is painted). |
41 // As |source| is cached for the lifetime of this object and the resize | 78 // As |source| is cached for the lifetime of this object and the resize |
42 // operation will most likely be performed on the UI thread, the maximum | 79 // operation will most likely be performed on the UI thread, the maximum |
43 // supported DIP size of |source| and |target_size_in_dip| is 64x64 DIP. | 80 // supported DIP size of |source| and |target_size_in_dip| is 64x64 DIP. |
44 // Resizing larger bitmaps should be done more explicitly using | 81 // Resizing larger bitmaps should be done more explicitly using |
45 // ImageOperations::Resize. | 82 // ImageOperations::Resize. |
46 static ImageSkia CreateResizedImage(const ImageSkia& source, | 83 static ImageSkia CreateResizedImage(const ImageSkia& source, |
47 const Size& target_size_in_dip); | 84 const Size& target_size_in_dip); |
48 | 85 |
49 private: | 86 private: |
50 ImageSkiaOperations(); // Class for scoping only. | 87 ImageSkiaOperations(); // Class for scoping only. |
51 }; | 88 }; |
52 | 89 |
53 } // namespace gfx | 90 } // namespace gfx |
54 | 91 |
55 #endif // UI_GFX_IMAGESKIA_OPERATIONS_H_ | 92 #endif // UI_GFX_IMAGESKIA_OPERATIONS_H_ |
OLD | NEW |