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 BASE_GFX_IMAGE_OPERATIONS_H__ | 5 #ifndef SKIA_EXT_IMAGE_OPERATIONS_H_ |
6 #define BASE_GFX_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 | 10 |
11 class SkBitmap; | 11 class SkBitmap; |
12 | 12 |
13 namespace gfx { | 13 namespace skia { |
14 | 14 |
15 class ImageOperations { | 15 class ImageOperations { |
16 public: | 16 public: |
17 enum ResizeMethod { | 17 enum ResizeMethod { |
18 // 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 |
19 // the destination pixel. For enlargement, this is nearest neighbor. | 19 // the destination pixel. For enlargement, this is nearest neighbor. |
20 // | 20 // |
21 // You probably don't want this, it is here for testing since it is easy to | 21 // You probably don't want this, it is here for testing since it is easy to |
22 // compute. Use RESIZE_LANCZOS3 instead. | 22 // compute. Use RESIZE_LANCZOS3 instead. |
23 RESIZE_BOX, | 23 RESIZE_BOX, |
24 | 24 |
25 // 3-cycle Lanczos filter. This is tall in the middle, goes negative on | 25 // 3-cycle Lanczos filter. This is tall in the middle, goes negative on |
26 // each side, then oscillates 2 more times. It gives nice sharp edges. | 26 // each side, then oscillates 2 more times. It gives nice sharp edges. |
27 RESIZE_LANCZOS3, | 27 RESIZE_LANCZOS3, |
28 }; | 28 }; |
29 | 29 |
30 // Resizes the given source bitmap using the specified resize method, so that | 30 // Resizes the given source bitmap using the specified resize method, so that |
31 // the entire image is (dest_size) big. The dest_subset is the rectangle in | 31 // the entire image is (dest_size) big. The dest_subset is the rectangle in |
32 // this destination image that should actually be returned. | 32 // this destination image that should actually be returned. |
33 // | 33 // |
34 // The output image will be (dest_subset.width(), dest_subset.height()). This | 34 // The output image will be (dest_subset.width(), dest_subset.height()). This |
35 // will save work if you do not need the entire bitmap. | 35 // will save work if you do not need the entire bitmap. |
36 // | 36 // |
37 // The destination subset must be smaller than the destination image. | 37 // The destination subset must be smaller than the destination image. |
38 static SkBitmap Resize(const SkBitmap& source, | 38 static SkBitmap Resize(const SkBitmap& source, |
39 ResizeMethod method, | 39 ResizeMethod method, |
40 const Size& dest_size, | 40 const gfx::Size& dest_size, |
41 const Rect& dest_subset); | 41 const gfx::Rect& dest_subset); |
42 | 42 |
43 // Alternate version for resizing and returning the entire bitmap rather than | 43 // Alternate version for resizing and returning the entire bitmap rather than |
44 // a subset. | 44 // a subset. |
45 static SkBitmap Resize(const SkBitmap& source, | 45 static SkBitmap Resize(const SkBitmap& source, |
46 ResizeMethod method, | 46 ResizeMethod method, |
47 const Size& dest_size); | 47 const gfx::Size& dest_size); |
48 | 48 |
49 | 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 private: | 56 private: |
57 ImageOperations(); // Class for scoping only. | 57 ImageOperations(); // Class for scoping only. |
58 }; | 58 }; |
59 | 59 |
60 } // namespace gfx | 60 } // namespace skia |
61 | 61 |
62 #endif // BASE_GFX_IMAGE_OPERATIONS_H__ | 62 #endif // SKIA_EXT_IMAGE_OPERATIONS_H_ |
63 | 63 |
OLD | NEW |