fc454367761ea3748ab55c20b214690a329e54f8
[platform/core/location/maps-plugin-here.git] / inc / engine / graphic / Grp_Util.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #ifndef HERE_GRAPHIC_UTIL_H
18 #define HERE_GRAPHIC_UTIL_H
19
20 #include "common/HereMaps_global.h"
21 #include "graphic/Grp_UtilType.h"
22 #include "graphic/Bitmap.h"
23 #include "graphic/PngDecoder.h"
24
25 TIZEN_MAPS_BEGIN_NAMESPACE
26
27 namespace _Util
28         {
29         bool IntersectRect(Rectangle<int>& outRect,
30                            const Rectangle<int>& srcRect1,
31                            const Rectangle<int>& srcRect2);
32
33         bool IntersectRect(Rectangle<float>& outRect,
34                            const Rectangle<float>& srcRect1,
35                            const Rectangle<float>& srcRect2);
36
37         long GetHashCode(const char *string);
38
39         EXPORT_API Bitmap* DecodePngToBmp(const byte* buffer, size_t size,
40                                                                                 MediaPixelFormat pixelFormat=MEDIA_PIXEL_FORMAT_RGBA8888);
41
42         EXPORT_API void ConvertRGBA2BGRA(void *data, unsigned int w, unsigned int h,
43                                                                                 MediaPixelFormat format=MEDIA_PIXEL_FORMAT_RGBA8888);
44
45         template<typename T>
46         inline T
47         Abs(const T& t)
48         {
49                 return (t >= 0) ? t : -t;
50         }
51
52         template<typename T>
53         inline T
54         Min(T a, T b)
55         {
56                 return (a < b) ? a : b;
57         }
58
59         template<typename T>
60         inline T
61         Max(T a, T b)
62         {
63                 return (a > b) ? a : b;
64         }
65 } // _Util
66
67 TIZEN_MAPS_END_NAMESPACE
68
69 #endif /* HERE_GRAPHIC_UTIL_H */