Tizen 2.1 base
[framework/osp/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         //
62         // This is the default constructor for this class.
63         //
64         _AppResourceBitmapUtil(void);
65
66         /**
67         * This is the destructor for this class.
68         */
69         virtual ~_AppResourceBitmapUtil(void);
70
71         result Construct(void);
72
73         result Construct(const Tizen::Base::String& appId);
74
75         // Generates the directory path from the specified resolution.
76         bool GetDirectoryPath(_Density resourceDirectory, Tizen::Base::String& dirPath) const;
77
78         bool GetDirectoryPath(_Density resourceDirectory, Tizen::Base::String& dirPath, const Tizen::Base::String& appId) const;
79
80         // Generates the real path using a pseudo-path and the specified resolution.
81         bool GetFilePath(const Tizen::Base::String& directoryPath, const Tizen::Base::String& fileName, Tizen::Base::String& filePath) const;
82
83         // The normalized path starts with and is divided by '/'.
84         // ex. L"/Dir1/Dir2/Dir3/File"
85         Tizen::Base::String NormalizePath(const Tizen::Base::String& path) const;
86
87         // Generates the real path and examine whether the size of the resource is logical or physical by processing the input path.
88         result GetResourcePath(const Tizen::Base::String& fileName, Tizen::Base::String& resourcePath, _Density& resourceDensity, bool& imageScaling) const;
89
90         // Create Bitmap from real image path
91         Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& resourcePath, _Density resourceDensity,
92                         Tizen::Graphics::BitmapPixelFormat pixelFormat, bool imageScaling, const Tizen::Graphics::Color* pChromaKeyColor = null) const;
93
94 private:
95         static const int DPI_FOR_XHIGH = 290;
96         static const int DPI_FOR_HIGH = 200;
97         static const int DPI_FOR_MIDDLE = 150;
98         static const int DPI_FOR_LOW = 0;
99
100         Tizen::Graphics::Dimension __physicalResolutionDim;
101         Tizen::Graphics::_BaseScreenSize __physicalBaseScreenSize;
102
103         // resource directory path for only device's resolution.
104         Tizen::Base::String __resolutionDirectories;
105
106         /**
107         * Index information of __sortedDensity & __sortedDensityDirectories.
108         * '0' is for screen density matched device's DPI.
109         * '1', '2', '3' is for screen density with fall back system.
110         */
111         _Density __sortedDensity[DENSITY_MAX];
112         Tizen::Base::String __sortedDensityDirectories[DENSITY_MAX];
113
114 }; // _AppResourceBitmapUtil
115
116 }} // Tizen::App
117
118 #endif // _FAPP_INTERNAL_APP_RESOURCE_BITMAP_UTIL_H_