mojo: Fix map of booleans for python bindings.
[chromium-blink-merge.git] / ui / gfx / image / image_skia_operations.h
blob5b81df7bbdbc8d9dcd7f81cab5c51d0d560f7541
1 // Copyright (c) 2012 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.
5 #ifndef UI_GFX_IMAGE_SKIA_OPERATIONS_H_
6 #define UI_GFX_IMAGE_SKIA_OPERATIONS_H_
8 #include "base/gtest_prod_util.h"
9 #include "skia/ext/image_operations.h"
10 #include "ui/gfx/color_utils.h"
11 #include "ui/gfx/gfx_export.h"
12 #include "ui/gfx/shadow_value.h"
13 #include "ui/gfx/skbitmap_operations.h"
15 namespace gfx {
16 class ImageSkia;
17 class Rect;
18 class Size;
20 class GFX_EXPORT ImageSkiaOperations {
21 public:
22 // Create an image that is a blend of two others. The alpha argument
23 // specifies the opacity of the second imag. The provided image must
24 // use the kARGB_8888_Config config and be of equal dimensions.
25 static ImageSkia CreateBlendedImage(const ImageSkia& first,
26 const ImageSkia& second,
27 double alpha);
29 // Creates an image that is the original image with opacity set to |alpha|.
30 static ImageSkia CreateTransparentImage(const ImageSkia& image, double alpha);
32 // Creates new image by painting first and second image respectively.
33 // The second image is centered in respect to the first image.
34 static ImageSkia CreateSuperimposedImage(const ImageSkia& first,
35 const ImageSkia& second);
37 // Create an image that is the original image masked out by the mask defined
38 // in the alpha image. The images must use the kARGB_8888_Config config and
39 // be of equal dimensions.
40 static ImageSkia CreateMaskedImage(const ImageSkia& first,
41 const ImageSkia& alpha);
43 // Create an image that is cropped from another image. This is special
44 // because it tiles the original image, so your coordinates can extend
45 // outside the bounds of the original image.
46 static ImageSkia CreateTiledImage(const ImageSkia& image,
47 int src_x, int src_y,
48 int dst_w, int dst_h);
50 // Shift an image's HSL values. The shift values are in the range of 0-1,
51 // with the option to specify -1 for 'no change'. The shift values are
52 // defined as:
53 // hsl_shift[0] (hue): The absolute hue value for the image - 0 and 1 map
54 // to 0 and 360 on the hue color wheel (red).
55 // hsl_shift[1] (saturation): A saturation shift for the image, with the
56 // following key values:
57 // 0 = remove all color.
58 // 0.5 = leave unchanged.
59 // 1 = fully saturate the image.
60 // hsl_shift[2] (lightness): A lightness shift for the image, with the
61 // following key values:
62 // 0 = remove all lightness (make all pixels black).
63 // 0.5 = leave unchanged.
64 // 1 = full lightness (make all pixels white).
65 static ImageSkia CreateHSLShiftedImage(const gfx::ImageSkia& image,
66 const color_utils::HSL& hsl_shift);
68 // Creates a button background image by compositing the color and image
69 // together, then applying the mask. This is a highly specialized composite
70 // operation that is the equivalent of drawing a background in |color|,
71 // tiling |image| over the top, and then masking the result out with |mask|.
72 // The images must use kARGB_8888_Config config.
73 static ImageSkia CreateButtonBackground(SkColor color,
74 const gfx::ImageSkia& image,
75 const gfx::ImageSkia& mask);
77 // Returns an image which is a subset of |image| with bounds |subset_bounds|.
78 // The |image| cannot use kA1_Config config.
79 static ImageSkia ExtractSubset(const gfx::ImageSkia& image,
80 const gfx::Rect& subset_bounds);
82 // Creates an image by resizing |source| to given |target_dip_size|.
83 static ImageSkia CreateResizedImage(const ImageSkia& source,
84 skia::ImageOperations::ResizeMethod methd,
85 const Size& target_dip_size);
87 // Creates an image with drop shadow defined in |shadows| for |source|.
88 static ImageSkia CreateImageWithDropShadow(const ImageSkia& source,
89 const ShadowValues& shadows);
91 // Creates an image which is a rotation of the |source|. |rotation| is the
92 // amount of clockwise rotation in degrees.
93 static ImageSkia CreateRotatedImage(
94 const ImageSkia& source,
95 SkBitmapOperations::RotationAmount rotation);
97 private:
98 ImageSkiaOperations(); // Class for scoping only.
101 } // namespace gfx
103 #endif // UI_GFX_IMAGE_IMAGE_SKIA_OPERATIONS_H_