license.bot | f003cfe | 2008-08-24 09:55:55 +0900 | [diff] [blame^] | 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 |
| 3 | // found in the LICENSE file. |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 4 | |
| 5 | #ifndef BASE_GFX_IMAGE_OPERATIONS_H__ |
| 6 | #define BASE_GFX_IMAGE_OPERATIONS_H__ |
| 7 | |
| 8 | #include "base/basictypes.h" |
| 9 | #include "base/gfx/rect.h" |
| 10 | |
| 11 | class SkBitmap; |
| 12 | |
| 13 | namespace gfx { |
| 14 | |
| 15 | class ImageOperations { |
| 16 | public: |
| 17 | enum ResizeMethod { |
| 18 | // Box filter. This is a weighted average of all of the pixels touching |
| 19 | // the destination pixel. For enlargement, this is nearest neighbor. |
| 20 | // |
| 21 | // You probably don't want this, it is here for testing since it is easy to |
| 22 | // compute. Use RESIZE_LANCZOS3 instead. |
| 23 | RESIZE_BOX, |
| 24 | |
| 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. |
| 27 | RESIZE_LANCZOS3, |
| 28 | }; |
| 29 | |
| 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 |
| 32 | // this destination image that should actually be returned. |
| 33 | // |
| 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. |
| 36 | // |
| 37 | // The destination subset must be smaller than the destination image. |
| 38 | static SkBitmap Resize(const SkBitmap& source, |
| 39 | ResizeMethod method, |
| 40 | const Size& dest_size, |
| 41 | const Rect& dest_subset); |
| 42 | |
| 43 | // Alternate version for resizing and returning the entire bitmap rather than |
| 44 | // a subset. |
| 45 | static SkBitmap Resize(const SkBitmap& source, |
| 46 | ResizeMethod method, |
| 47 | const Size& dest_size); |
| 48 | |
| 49 | |
| 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 |
| 52 | // use have the kARGB_8888_Config config and be of equal dimensions. |
| 53 | static SkBitmap CreateBlendedBitmap(const SkBitmap& first, |
| 54 | const SkBitmap& second, |
| 55 | double alpha); |
| 56 | private: |
| 57 | ImageOperations(); // Class for scoping only. |
| 58 | }; |
| 59 | |
| 60 | } // namespace gfx |
| 61 | |
| 62 | #endif // BASE_GFX_IMAGE_OPERATIONS_H__ |
license.bot | f003cfe | 2008-08-24 09:55:55 +0900 | [diff] [blame^] | 63 | |