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