| 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 "skia/ext/skia_utils.h" | 10 #include "skia/ext/skia_utils.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 static SkBitmap CreateBlendedBitmap(const SkBitmap& first, | 54 static SkBitmap CreateBlendedBitmap(const SkBitmap& first, |
| 55 const SkBitmap& second, | 55 const SkBitmap& second, |
| 56 double alpha); | 56 double alpha); |
| 57 | 57 |
| 58 // Create a bitmap that is the original bitmap masked out by the mask defined | 58 // Create a bitmap that is the original bitmap masked out by the mask defined |
| 59 // in the alpha bitmap. The images must use the kARGB_8888_Config config and | 59 // in the alpha bitmap. The images must use the kARGB_8888_Config config and |
| 60 // be of equal dimensions. | 60 // be of equal dimensions. |
| 61 static SkBitmap CreateMaskedBitmap(const SkBitmap& first, | 61 static SkBitmap CreateMaskedBitmap(const SkBitmap& first, |
| 62 const SkBitmap& alpha); | 62 const SkBitmap& alpha); |
| 63 | 63 |
| 64 // We create a button background image by compositing the color and image | 64 // We create a button background image by compositing the color and image |
| 65 // together, then applying the mask. This is a highly specialized composite | 65 // together, then applying the mask. This is a highly specialized composite |
| 66 // operation that is the equivalent of drawing a background in |color|, | 66 // operation that is the equivalent of drawing a background in |color|, |
| 67 // tiling |image| over the top, and then masking the result out with |mask|. | 67 // tiling |image| over the top, and then masking the result out with |mask|. |
| 68 // The images must use kARGB_8888_Config config. | 68 // The images must use kARGB_8888_Config config. |
| 69 static SkBitmap CreateButtonBackground(SkColor color, | 69 static SkBitmap CreateButtonBackground(SkColor color, |
| 70 const SkBitmap& image, | 70 const SkBitmap& image, |
| 71 const SkBitmap& mask); | 71 const SkBitmap& mask); |
| 72 | 72 |
| 73 // Blur a bitmap using an average-blur algorithm over the rectangle defined | 73 // Blur a bitmap using an average-blur algorithm over the rectangle defined |
| 74 // by |blur_amount|. The blur will wrap around image edges. | 74 // by |blur_amount|. The blur will wrap around image edges. |
| 75 static SkBitmap CreateBlurredBitmap(const SkBitmap& bitmap, int blur_amount); | 75 static SkBitmap CreateBlurredBitmap(const SkBitmap& bitmap, int blur_amount); |
| 76 | 76 |
| 77 // Shift a bitmap's HSL values. The shift values are in the range of 0-1, | 77 // Shift a bitmap's HSL values. The shift values are in the range of 0-1, |
| 78 // with the option to specify -1 for 'no change'. The shift values are | 78 // with the option to specify -1 for 'no change'. The shift values are |
| 79 // defined as: | 79 // defined as: |
| 80 // hsl_shift[0] (hue): The absolute hue value for the image - 0 and 1 map | 80 // hsl_shift[0] (hue): The absolute hue value for the image - 0 and 1 map |
| 81 // to 0 and 360 on the hue color wheel (red). | 81 // to 0 and 360 on the hue color wheel (red). |
| 82 // hsl_shift[1] (saturation): A saturation shift for the image, with the | 82 // hsl_shift[1] (saturation): A saturation shift for the image, with the |
| 83 // following key values: | 83 // following key values: |
| 84 // 0 = remove all color. | 84 // 0 = remove all color. |
| 85 // 0.5 = leave unchanged. | 85 // 0.5 = leave unchanged. |
| 86 // 1 = fully saturate the image. | 86 // 1 = fully saturate the image. |
| 87 // hsl_shift[2] (lightness): A lightness shift for the image, with the | 87 // hsl_shift[2] (lightness): A lightness shift for the image, with the |
| 88 // following key values: | 88 // following key values: |
| 89 // 0 = remove all lightness (make all pixels black). | 89 // 0 = remove all lightness (make all pixels black). |
| 90 // 0.5 = leave unchanged. | 90 // 0.5 = leave unchanged. |
| 91 // 1 = full lightness (make all pixels white). | 91 // 1 = full lightness (make all pixels white). |
| 92 static SkBitmap CreateHSLShiftedBitmap(const SkBitmap& bitmap, | 92 static SkBitmap CreateHSLShiftedBitmap(const SkBitmap& bitmap, |
| 93 HSL hsl_shift); | 93 HSL hsl_shift); |
| 94 | 94 |
| 95 // Create a bitmap that is cropped from another bitmap. This is special | 95 // Create a bitmap that is cropped from another bitmap. This is special |
| 96 // because it tiles the original bitmap, so your coordinates can extend | 96 // because it tiles the original bitmap, so your coordinates can extend |
| 97 // outside the bounds of the original image. | 97 // outside the bounds of the original image. |
| 98 static SkBitmap CreateTiledBitmap(const SkBitmap& bitmap, | 98 static SkBitmap CreateTiledBitmap(const SkBitmap& bitmap, |
| 99 int src_x, int src_y, | 99 int src_x, int src_y, |
| 100 int dst_w, int dst_h); | 100 int dst_w, int dst_h); |
| 101 |
| 102 // Makes a bitmap half has large in each direction by averaging groups of |
| 103 // 4 pixels. This is one step in generating a mipmap. |
| 104 static SkBitmap DownsampleByTwo(const SkBitmap& bitmap); |
| 105 |
| 106 // Iteratively downsamples by 2 until the bitmap is no smaller than the |
| 107 // input size. The normal use of this is to downsample the bitmap "close" to |
| 108 // the final size, and then use traditional resampling on the result. |
| 109 // Because the bitmap will be closer to the final size, it will be faster, |
| 110 // and linear interpolation will generally work well as a second step. |
| 111 static SkBitmap DownsampleByTwoUntilSize(const SkBitmap& bitmap, |
| 112 int min_w, int min_h); |
| 113 |
| 101 private: | 114 private: |
| 102 ImageOperations(); // Class for scoping only. | 115 ImageOperations(); // Class for scoping only. |
| 103 }; | 116 }; |
| 104 | 117 |
| 105 } // namespace skia | 118 } // namespace skia |
| 106 | 119 |
| 107 #endif // SKIA_EXT_IMAGE_OPERATIONS_H_ | 120 #endif // SKIA_EXT_IMAGE_OPERATIONS_H_ |
| 108 | 121 |
| OLD | NEW |