Adjust the position of the partial Frame
[platform/framework/native/uifw.git] / src / app / FApp_AppResourceBitmapUtil.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FApp_AppResourceBitmapUtil.h
20  * @brief       This is the header file of the _AppResourceBitmapUtil.
21  */
22
23 #ifndef _FAPP_INTERNAL_APP_RESOURCE_BITMAP_UTIL_H_
24 #define _FAPP_INTERNAL_APP_RESOURCE_BITMAP_UTIL_H_
25
26 #include <FBaseString.h>
27 #include <FIoFile.h>
28 #include <FGrpBitmap.h>
29 #include <FGrp_BitmapImpl.h>
30 #include <FGrp_CoordinateSystem.h>
31
32 namespace Tizen { namespace Graphics
33 {
34 class Bitmap;
35 class Color;
36 }} // Tizen::Graphics
37
38 namespace Tizen { namespace Media
39 {
40 class Image;
41 }} // Tizen::Media
42
43 namespace Tizen { namespace App
44 {
45 class _AppResourceBitmapUtil
46         : public Tizen::Base::Object
47 {
48 public:
49         enum _Density
50         {
51                 DENSITY_NONE = -1,
52
53                 DENSITY_LOW = 0,
54                 DENSITY_MIDDLE = 1,
55                 DENSITY_HIGH = 2,
56                 DENSITY_XHIGH = 3,
57
58                 DENSITY_MAX = 4
59         };
60
61         enum AppResourceBy
62         {
63                 APP_RESOURCE_DEFAULT,
64                 APP_RESOURCE_BY_APP_ID,
65                 APP_RESOURCE_BY_LIBRARY_NAME,
66                 APP_RESOURCE_BITMAP
67         };
68
69         // This is the default constructor for this class.
70         _AppResourceBitmapUtil(void);
71
72         // This is the destructor for this class.
73         virtual ~_AppResourceBitmapUtil(void);
74
75         //Get device's DPI, application's logical resolution and set fall back system
76         result Construct(const Tizen::Base::String& resourceFolder);
77
78         // Generates the directory path from the specified resolution.
79         bool GetDirectoryPath(const Tizen::Base::String& homePath, _Density resourceDirectory, Tizen::Base::String& dirPath) const;
80
81         // Generates the real path using a pseudo-path and the specified resolution.
82         bool GetFilePath(const Tizen::Base::String& directoryPath, const Tizen::Base::String& fileName, Tizen::Base::String& filePath) const;
83
84         // The normalized path starts with and is divided by '/'.
85         // ex. L"/Dir1/Dir2/Dir3/File"
86         Tizen::Base::String NormalizePath(const Tizen::Base::String& path) const;
87
88         // Generates the real path and examine whether the size of the resource is logical or physical by processing the input path.
89         result GetResourcePath(const Tizen::Base::String& fileName, Tizen::Base::String& resourcePath, _Density& resourceDensity, bool& imageScaling) const;
90
91         // Create Bitmap from real image path
92         Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& resourcePath, _Density resourceDensity,
93                         Tizen::Graphics::BitmapPixelFormat pixelFormat, bool imageScaling, const Tizen::Graphics::Color* pChromaKeyColor = null) const;
94
95         static _AppResourceBitmapUtil* GetInstanceN(int type = APP_RESOURCE_DEFAULT, const Tizen::Base::String& value = L"");
96
97         Tizen::App::_AppResourceBitmapUtil::AppResourceBy GetAppResourceType(void);
98         
99 private:
100         // This is the copy constructor for this class.
101         _AppResourceBitmapUtil(const _AppResourceBitmapUtil& rhs);
102
103         // This is the assignment operator for this class.
104         _AppResourceBitmapUtil& operator =(const _AppResourceBitmapUtil& rhs);
105
106 private:
107         static const int DPI_FOR_XHIGH = 290;
108         static const int DPI_FOR_HIGH = 200;
109         static const int DPI_FOR_MIDDLE = 150;
110         static const int DPI_FOR_LOW = 0;
111
112         Tizen::Graphics::Dimension __physicalResolutionDim;
113         Tizen::Graphics::_BaseScreenSize __physicalBaseScreenSize;
114
115         // resource directory path for only device's resolution.
116         Tizen::Base::String __resolutionDirectories;
117
118         /**
119         * Index information of __sortedDensity & __sortedDensityDirectories.
120         * '0' is for screen density matched device's DPI.
121         * '1', '2', '3' is for screen density with fall back system.
122         */
123         _Density __sortedDensity[DENSITY_MAX];
124         Tizen::Base::String __sortedDensityDirectories[DENSITY_MAX];
125
126         Tizen::App::_AppResourceBitmapUtil::AppResourceBy __resourceType;
127
128 }; // _AppResourceBitmapUtil
129
130 }} // Tizen::App
131
132 #endif // _FAPP_INTERNAL_APP_RESOURCE_BITMAP_UTIL_H_