OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 SKIA_EXT_IMAGE_OPERATIONS_H_ | 5 #ifndef SKIA_EXT_IMAGE_OPERATIONS_H_ |
6 #define SKIA_EXT_IMAGE_OPERATIONS_H_ | 6 #define SKIA_EXT_IMAGE_OPERATIONS_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/gfx/rect.h" | 9 #include "base/gfx/rect.h" |
10 #include "SkColor.h" | |
11 | 10 |
12 class SkBitmap; | 11 class SkBitmap; |
13 | 12 |
14 namespace skia { | 13 namespace skia { |
15 | 14 |
16 class ImageOperations { | 15 class ImageOperations { |
17 public: | 16 public: |
18 enum ResizeMethod { | 17 enum ResizeMethod { |
19 // Box filter. This is a weighted average of all of the pixels touching | 18 // Box filter. This is a weighted average of all of the pixels touching |
20 // the destination pixel. For enlargement, this is nearest neighbor. | 19 // the destination pixel. For enlargement, this is nearest neighbor. |
(...skipping 19 matching lines...) Expand all Loading... |
40 ResizeMethod method, | 39 ResizeMethod method, |
41 int dest_width, int dest_height, | 40 int dest_width, int dest_height, |
42 const gfx::Rect& dest_subset); | 41 const gfx::Rect& dest_subset); |
43 | 42 |
44 // Alternate version for resizing and returning the entire bitmap rather than | 43 // Alternate version for resizing and returning the entire bitmap rather than |
45 // a subset. | 44 // a subset. |
46 static SkBitmap Resize(const SkBitmap& source, | 45 static SkBitmap Resize(const SkBitmap& source, |
47 ResizeMethod method, | 46 ResizeMethod method, |
48 int dest_width, int dest_height); | 47 int dest_width, int dest_height); |
49 | 48 |
| 49 |
50 // Create a bitmap that is a blend of two others. The alpha argument | 50 // Create a bitmap that is a blend of two others. The alpha argument |
51 // specifies the opacity of the second bitmap. The provided bitmaps must | 51 // specifies the opacity of the second bitmap. The provided bitmaps must |
52 // use have the kARGB_8888_Config config and be of equal dimensions. | 52 // use have the kARGB_8888_Config config and be of equal dimensions. |
53 static SkBitmap CreateBlendedBitmap(const SkBitmap& first, | 53 static SkBitmap CreateBlendedBitmap(const SkBitmap& first, |
54 const SkBitmap& second, | 54 const SkBitmap& second, |
55 double alpha); | 55 double alpha); |
56 | |
57 // Create a bitmap that is the original bitmap masked out by the mask defined | |
58 // in the alpha bitmap. The images must use the kARGB_8888_Config config and | |
59 // be of equal dimensions. | |
60 static SkBitmap CreateMaskedBitmap(const SkBitmap& first, | |
61 const SkBitmap& alpha); | |
62 | |
63 // Blur a bitmap using an average-blur algorithm over the rectangle defined | |
64 // by |blur_amount|. The blur will wrap around image edges. | |
65 static SkBitmap CreateBlurredBitmap(const SkBitmap& bitmap, int blur_amount); | |
66 | |
67 // Shift a bitmap's HSL values. The shift values are in the range of 0-1, | |
68 // with the option to specify -1 for 'no change'. The shift values are | |
69 // defined as: | |
70 // hsl_shift[0] (hue): The absolute hue value for the image - 0 and 1 map | |
71 // to 0 and 360 on the hue color wheel (red). | |
72 // hsl_shift[1] (saturation): A saturation shift for the image, with the | |
73 // following key values: | |
74 // 0 = remove all color. | |
75 // 0.5 = leave unchanged. | |
76 // 1 = fully saturate the image. | |
77 // hsl_shift[2] (lightness): A lightness shift for the image, with the | |
78 // following key values: | |
79 // 0 = remove all lightness (make all pixels black). | |
80 // 0.5 = leave unchanged. | |
81 // 1 = full lightness (make all pixels white). | |
82 static SkBitmap CreateHSLShiftedBitmap(const SkBitmap& bitmap, | |
83 float hsl_shift[3]); | |
84 | |
85 // Create a bitmap that is cropped from another bitmap. This is special | |
86 // because it tiles the original bitmap, so your coordinates can extend | |
87 // outside the bounds of the original image. | |
88 static SkBitmap CreateTiledBitmap(const SkBitmap& bitmap, | |
89 int src_x, int src_y, | |
90 int dst_w, int dst_h); | |
91 private: | 56 private: |
92 ImageOperations(); // Class for scoping only. | 57 ImageOperations(); // Class for scoping only. |
93 }; | 58 }; |
94 | 59 |
95 } // namespace skia | 60 } // namespace skia |
96 | 61 |
97 #endif // SKIA_EXT_IMAGE_OPERATIONS_H_ | 62 #endif // SKIA_EXT_IMAGE_OPERATIONS_H_ |
98 | 63 |
OLD | NEW |