summaryrefslogtreecommitdiffstats
path: root/skia/ext/image_operations.h
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-09 17:45:03 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-09 17:45:03 +0000
commitcd5749d607e9edec80d648723360aa1e8ef181c1 (patch)
tree7f2c7cd4cbd81122b38e846e19b0b037d00b07bd /skia/ext/image_operations.h
parent9a556e3307dacc7e6d84517d3b78b86c6dbd84f1 (diff)
downloadchromium_src-cd5749d607e9edec80d648723360aa1e8ef181c1.zip
chromium_src-cd5749d607e9edec80d648723360aa1e8ef181c1.tar.gz
chromium_src-cd5749d607e9edec80d648723360aa1e8ef181c1.tar.bz2
Add a mipmap-like divide-by-two image scaling algorithm. I am going to use this
for on-the-fly generated thumbnails. Review URL: http://codereview.chromium.org/118341 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17957 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext/image_operations.h')
-rw-r--r--skia/ext/image_operations.h27
1 files changed, 20 insertions, 7 deletions
diff --git a/skia/ext/image_operations.h b/skia/ext/image_operations.h
index 4e3c93e..3b172c8 100644
--- a/skia/ext/image_operations.h
+++ b/skia/ext/image_operations.h
@@ -61,9 +61,9 @@ class ImageOperations {
static SkBitmap CreateMaskedBitmap(const SkBitmap& first,
const SkBitmap& alpha);
- // We create a button background image by compositing the color and image
- // together, then applying the mask. This is a highly specialized composite
- // operation that is the equivalent of drawing a background in |color|,
+ // We create a button background image by compositing the color and image
+ // together, then applying the mask. This is a highly specialized composite
+ // operation that is the equivalent of drawing a background in |color|,
// tiling |image| over the top, and then masking the result out with |mask|.
// The images must use kARGB_8888_Config config.
static SkBitmap CreateButtonBackground(SkColor color,
@@ -74,17 +74,17 @@ class ImageOperations {
// by |blur_amount|. The blur will wrap around image edges.
static SkBitmap CreateBlurredBitmap(const SkBitmap& bitmap, int blur_amount);
- // Shift a bitmap's HSL values. The shift values are in the range of 0-1,
- // with the option to specify -1 for 'no change'. The shift values are
+ // Shift a bitmap's HSL values. The shift values are in the range of 0-1,
+ // with the option to specify -1 for 'no change'. The shift values are
// defined as:
// hsl_shift[0] (hue): The absolute hue value for the image - 0 and 1 map
// to 0 and 360 on the hue color wheel (red).
- // hsl_shift[1] (saturation): A saturation shift for the image, with the
+ // hsl_shift[1] (saturation): A saturation shift for the image, with the
// following key values:
// 0 = remove all color.
// 0.5 = leave unchanged.
// 1 = fully saturate the image.
- // hsl_shift[2] (lightness): A lightness shift for the image, with the
+ // hsl_shift[2] (lightness): A lightness shift for the image, with the
// following key values:
// 0 = remove all lightness (make all pixels black).
// 0.5 = leave unchanged.
@@ -98,6 +98,19 @@ class ImageOperations {
static SkBitmap CreateTiledBitmap(const SkBitmap& bitmap,
int src_x, int src_y,
int dst_w, int dst_h);
+
+ // Makes a bitmap half has large in each direction by averaging groups of
+ // 4 pixels. This is one step in generating a mipmap.
+ static SkBitmap DownsampleByTwo(const SkBitmap& bitmap);
+
+ // Iteratively downsamples by 2 until the bitmap is no smaller than the
+ // input size. The normal use of this is to downsample the bitmap "close" to
+ // the final size, and then use traditional resampling on the result.
+ // Because the bitmap will be closer to the final size, it will be faster,
+ // and linear interpolation will generally work well as a second step.
+ static SkBitmap DownsampleByTwoUntilSize(const SkBitmap& bitmap,
+ int min_w, int min_h);
+
private:
ImageOperations(); // Class for scoping only.
};