Tizen 2.4.0 rev3 SDK Public Release
[framework/graphics/dali.git] / dali / public-api / images / image-operations.h
1 #ifndef __DALI_IMAGE_OPERATIONS_H__
2 #define __DALI_IMAGE_OPERATIONS_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22
23 // INTERNAL INCLUDES
24 #include <dali/public-api/math/uint-16-pair.h>
25
26 namespace Dali
27 {
28 /**
29  * @addtogroup dali_core_images
30  * @{
31  */
32
33 /**
34  * @brief The integer dimensions of an image or a region of an image packed into
35  *        16 bits per component.
36  *
37  * This can only be used for images of up to 65535 x 65535 pixels.
38  * @since_tizen 2.4
39  */
40 typedef Uint16Pair ImageDimensions;
41
42 /**
43  * @brief Fitting options, used when resizing images to fit desired dimensions.
44  *
45  * A fitting mode controls the region of a loaded image to be mapped to the
46  * desired image rectangle.
47  * All fitting modes preserve the aspect ratio of the image contents.
48  * @since_tizen 2.4
49  */
50 namespace FittingMode
51 {
52   enum Type
53   {
54     /// @brief Fit full image inside desired width & height, potentially not
55     /// filling one of either the desired image width or height with
56     /// pixels.
57     /// @since_tizen 2.4
58     SHRINK_TO_FIT,
59
60     /// @brief Image fills whole desired width & height with image data. The
61     /// image is centred in the desired dimensions, exactly touching
62     /// in one dimension, with image regions outside the other desired
63     /// dimension cropped away.
64     /// @since_tizen 2.4
65     SCALE_TO_FILL,
66
67     /// @brief Image fills whole width. Height is scaled proportionately to
68     /// maintain aspect ratio.
69     /// @since_tizen 2.4
70     FIT_WIDTH,
71
72     /// @brief Image fills whole height. Width is scaled proportionately to
73     /// maintain aspect ratio.
74     /// @since_tizen 2.4
75     FIT_HEIGHT
76   };
77   const Type DEFAULT = SHRINK_TO_FIT;
78 }
79
80 /**
81  * @brief Filtering options, used when resizing images to sample original pixels.
82  *
83  * A SamplingMode controls how pixels in an input image are sampled and
84  * combined to generate each pixel of a destination image during a scaling.
85  *
86  * NoFilter and Box modes do not guarantee that the output pixel array
87  * exactly matches the rectangle specified by the desired dimensions and
88  * FittingMode, but all other filter modes do if the desired dimensions are
89  * `<=` the raw dimensions of the input image file.
90  * @since_tizen 2.4
91  */
92 namespace SamplingMode
93 {
94   enum Type
95   {
96     /// @brief Iteratively box filter to generate an image of 1/2, 1/4,
97     /// 1/8, etc width and height and approximately the desired
98     /// size. This is the default.
99     /// @since_tizen 2.4
100     BOX,
101
102     /// @brief For each output pixel, read one input pixel.
103     /// @since_tizen 2.4
104     NEAREST,
105
106     /// @brief For each output pixel, read a quad of four input pixels
107     /// and write a weighted average of them.
108     /// @since_tizen 2.4
109     LINEAR,
110
111     /// @brief Iteratively box filter to generate an image of 1/2, 1/4,
112     /// 1/8 etc width and height and approximately the desired
113     /// size, then for each output pixel, read one pixel from the
114     /// last level of box filtering.
115     /// @since_tizen 2.4
116     BOX_THEN_NEAREST,
117
118     /// @brief Iteratively box filter to almost the right size, then for
119     /// each output pixel, read four pixels from the last level of
120     /// box filtering and write their weighted average.
121     /// @since_tizen 2.4
122     BOX_THEN_LINEAR,
123
124     /// @brief No filtering is performed. If the SCALE_TO_FILL scaling mode
125     /// is enabled, the borders of the image may be trimmed to
126     /// match the aspect ratio of the desired dimensions.
127     /// @since_tizen 2.4
128     NO_FILTER,
129
130     /// @brief For caching algorithms where a client strongly prefers a
131     /// cache-hit to reuse a cached image.
132     /// @since_tizen 2.4
133     DONT_CARE
134   };
135   const Type DEFAULT = BOX;
136 }
137
138 /**
139  * @}
140  */
141 } // namespace Dali
142
143 #endif // __DALI_IMAGE_OPERATIONS_H__