Formatting API
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / utility / npatch-utilities.h
1 #ifndef DALI_TOOLKIT_NPATCH_UTILITIES_H
2 #define DALI_TOOLKIT_NPATCH_UTILITIES_H
3
4 /*
5  * Copyright (c) 2020 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 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
23 #include <dali/public-api/common/dali-vector.h>
24 #include <dali/public-api/math/uint-16-pair.h>
25
26 // INTERNAL INCLUDES
27 #include <dali-toolkit/public-api/dali-toolkit-common.h>
28
29 namespace Dali
30 {
31 namespace Toolkit
32 {
33 namespace NPatchUtility
34 {
35 /**
36  * The list that includes stretch pixel ranges
37  */
38 using StretchRanges = Dali::Vector<Uint16Pair>;
39
40 /**
41  * @brief Get the offset of the red channel for the format.
42  *
43  * @param[in] pixelFormat The pixel format
44  * @param[out] byteOffset The byte offset of the red channel.
45  * @param[out] bitMask The bit mask of the red channel.
46  */
47 DALI_TOOLKIT_API void GetRedOffsetAndMask(Dali::Pixel::Format pixelFormat, int& byteOffset, int& bitMask);
48
49 /**
50  * @brief Read the borders of the buffer and determine the child area and stretch borders.
51  *
52  * @param[in] pixelBuffer The npatch image buffer.
53  * @param[out] stretchPixelsX The horizontal stretchable pixels in the cropped image space.
54  * @param[out] stretchPixelsY The vertical stretchable pixels in the cropped image space.
55  */
56 DALI_TOOLKIT_API void ParseBorders(Devel::PixelBuffer& pixelBuffer, StretchRanges& stretchPixelsX, StretchRanges& stretchPixelsY);
57
58 /**
59  * @brief Helper method to determine if the filename indicates that the image has a 9 patch or n patch border.
60  *
61  * @param [in] url The URL of the image file.
62  * @return true if it is a 9 patch or n patch image
63  */
64 DALI_TOOLKIT_API bool IsNinePatchUrl(const std::string& url);
65
66 } // namespace NPatchUtility
67
68 } // namespace Toolkit
69
70 } // namespace Dali
71
72 #endif // DALI_TOOLKIT_NPATCH_UTILITIES_H