Tizen 2.1 base
[framework/osp/uifw.git] / src / app / FApp_AppResourceBitmap.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_AppResourceBitmap.h
20  * @brief       This is the header file of the _AppResourceBitmap class.
21  */
22
23 #ifndef _FAPP_INTERNAL_APP_RESOURCE_BITMAP_H_
24 #define _FAPP_INTERNAL_APP_RESOURCE_BITMAP_H_
25
26 #include <unique_ptr.h>
27
28 #include <FBaseObject.h>
29 #include <FBaseString.h>
30 #include <FOspConfig.h>
31 #include "FApp_IAppResourceBitmap.h"
32
33 namespace Tizen { namespace App
34 {
35 class _AppResourceBitmapUtil;
36
37 class _AppResourceBitmap
38         : public Tizen::Base::Object
39         , public _IAppResourceBitmap
40 {
41 public:
42         /**
43         * Gets the bitmap at the specified path. @n
44         * The %GetBitmapN() method interprets the given resource path and reads the best matching image file for the current device resolution. @n
45         * To load the bitmap image from a file, give the name of the file as the input parameter and not the file path (For example: "img.png").
46         * Then, the system will first look for the image file in the folder specific to the current device resolution, such as
47         * '720x1280' and if the file does not exist, it will then search the folder that corresponds to the current screen density,
48         * such as 'screen-density-xhigh'. After searching the density folder, all the other density folders are searched in the order high to low.
49         * Currently supported image formats are: JPEG, GIF, PNG, BMP, TIFF, and WBMP.
50         *
51         * In this method, the system decides the proper pixel format.
52         * Currently supported image formats are: JPEG, GIF, PNG, BMP, TIFF, and WBMP.
53         *
54         * @since                2.0
55         *
56         * @return               A pointer to the Tizen::Graphics::Bitmap instance generated from the specified file
57         * @param[in]    imagePath                               The relative path starting from the density directory @b "res/screen-density-XXX/" or @b "res/AxB", @n
58         *                                                                               where A and B represent the width and height of the screen of the supported device models, respectively
59         * @exception    E_SUCCESS                               The method is successful.
60         * @exception    E_INVALID_ARG                   The specified input parameter is invalid.
61         * @exception    E_UNSUPPORTED_FORMAT    The image file format is not supported.
62         * @exception    E_FILE_NOT_FOUND                The specified file cannot be found.
63         * @exception    E_SYSTEM                                A system error has occurred.
64         * @remarks      The specific error code can be accessed using the GetLastResult() method.
65         * @remarks      There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, refer <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
66         */
67         virtual Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat) const;
68
69         static _AppResourceBitmap* GetInstance(void);
70
71         static _AppResourceBitmap* GetInstanceByAppId(const Tizen::Base::String& appId);
72
73 private:
74         /**
75         * This is the default constructor for this class.
76         */
77         _AppResourceBitmap(void);
78
79         /**
80         * This is the copy constructor for this class.
81         */
82         _AppResourceBitmap(const _AppResourceBitmap& rhs);
83
84         /**
85         * This is the destructor for this class.
86         */
87         virtual ~_AppResourceBitmap(void);
88
89         /**
90         * Initializes this instance of _AppResourceBitmap.
91         */
92         result Construct(void);
93
94         result Construct(const Tizen::Base::String& appId);
95
96         /**
97          * This is the assignment operator for this class.
98          */
99         _AppResourceBitmap& operator =(const _AppResourceBitmap& rhs);
100
101         static void InitAppResourceBitmap(void);
102
103 private:
104         std::unique_ptr<_AppResourceBitmapUtil> __pAppResourceBitmapUtil;
105
106         static _AppResourceBitmap* __pTheInstance;
107
108 }; // _AppResourceBitmap
109
110 }} // Tizen::App
111
112 #endif // _FAPP_INTERNAL_APP_RESOURCE_BITMAP_H_