1 #ifndef DALI_TOOLKIT_NPATCH_UTILITIES_H
2 #define DALI_TOOLKIT_NPATCH_UTILITIES_H
5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
27 #include <dali-toolkit/public-api/dali-toolkit-common.h>
33 namespace NPatchUtility
36 * The list that includes stretch pixel ranges
38 using StretchRanges = Dali::Vector<Uint16Pair>;
41 * @brief Get the offset of the red channel for the format.
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.
47 DALI_TOOLKIT_API void GetRedOffsetAndMask(Dali::Pixel::Format pixelFormat, int& byteOffset, int& bitMask);
50 * @brief Read the borders of the buffer and determine the child area and stretch borders.
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.
56 DALI_TOOLKIT_API void ParseBorders(Devel::PixelBuffer& pixelBuffer, StretchRanges& stretchPixelsX, StretchRanges& stretchPixelsY);
59 * @brief Helper method to determine if the filename indicates that the image has a 9 patch or n patch border.
61 * @param [in] url The URL of the image file.
62 * @return true if it is a 9 patch or n patch image
64 DALI_TOOLKIT_API bool IsNinePatchUrl(const std::string& url);
66 } // namespace NPatchUtility
68 } // namespace Toolkit
72 #endif // DALI_TOOLKIT_NPATCH_UTILITIES_H