2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FApp_AppResourceImpl.h
19 * @brief This is the header file of the _AppResourceImpl class.
22 #ifndef _FAPP_INTERNAL_APP_RESOURCE_IMPL_H_
23 #define _FAPP_INTERNAL_APP_RESOURCE_IMPL_H_
25 #include <FBaseObject.h>
26 #include <FBaseString.h>
28 #include <FGrpBitmapCommon.h>
30 namespace Tizen { namespace Base { namespace Collection { class HashMap; } } }
31 namespace Tizen { namespace Graphics { class Bitmap; } }
33 namespace Tizen { namespace App
37 class _AppResourceString;
38 class _IAppResourceBitmap;
43 APP_RESOURCE_BY_APP_ID,
44 APP_RESOURCE_BY_LIBRARY_NAME,
48 class _AppResourceImpl
49 : public Tizen::Base::Object
53 * This is the destructor for this class.
57 virtual ~_AppResourceImpl(void);
60 * Gets the string at the specified resource ID.
63 * @return An error code
64 * @param[in] resourceId The resource ID describing the String resource
65 * @param[out] loadedString The string obtained from the loaded application resource
66 * @exception E_SUCCESS The method was successful.
67 * @exception E_FAILURE The argument passed is not found.
68 * @exception E_INVALID_ARG The argument passed to a method contains an invalid resource ID.
70 result GetString(const Tizen::Base::String& resourceId, Tizen::Base::String& loadedString);
73 * Gets the Bitmap at the specified path. @n
74 * This method interprets the given resource path and reads the best matching image file for the current device resolution. @n
75 * To load bitmap image from a file, you give the name of file as the input parameter not the file path (Ex: "img.png").
76 * Then, the system will first look for the image file in the folder specific to the current device resolution such as
77 * '320x480' and if the file does not exist, it will then search the folder that corresponds to the current screen density,
78 * such as 'ScreenDensity-Middle'. After searching density folder, all other density folders are searched in the order high to low.
79 * Currently supported image formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
83 * @return A Bitmap instance generated from the specified file
84 * @param[in] imagePath The relative path starting from the directory "/res/screen-density-XXX/", @n
85 * where A and B represents the screen width and height of the supported device models, respectively.
86 * @param[in] pixelFormat The pixel format of the resulting bitmap
87 * @exception E_SUCCESS The method was successful.
88 * @exception E_INVALID_ARG A specified input parameter is invalid.
89 * @exception E_UNSUPPORTED_FORMAT The image file format or specified pixel format is not supported.
90 * @exception E_OUT_OF_MEMORY Insufficient memory.
91 * @exception E_FILE_NOT_FOUND The specified file could not be found.
92 * @exception E_SYSTEM A system error occurred.
94 Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat);
97 * Gets the Bitmap at the specified path. @n
98 * This method interprets the given resource path and reads the best matching image file for the current device resolution. @n
99 * To load bitmap image from a file, you give the name of file as the input parameter not the file path (Ex: "img.png").
100 * Then, the system will first look for the image file in the folder specific to the current device resolution such as
101 * '320x480' and if the file does not exist, it will then search the folder that corresponds to the current screen density,
102 * such as 'ScreenDensity-Middle'. After searching density folder, all other density folders are searched in the order high to low.
103 * Currently supported image formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
105 * In this method, the system decides the proper pixel format and whether to use chroma key composition to enable transparency. @n
106 * If the input image file has the alpha channel, the pixel format is set to Tizen::Graphics::BITMAP_PIXEL_FORMAT_ARGB8888.
107 * Otherwise, the pixel format is set to BITMAP_PIXEL_FORMAT_RGB565 and the masking color of the bitmap is set to magenta, Tizen::Graphics::Color(255, 0, 255). @n
108 * Typically, a WVGA Tizen device would support alpha channel, while WQVGA device would support bitmap with masking color, to support transparency.
109 * You can place a 32-bit version of the resource and a 16-bit version in the WQVGA resource folder at the same folder. To distinguish the pixel format, you can use a postfix '@@16' such as 'image@@.bmp'.
110 * If you don't use postfix, this API would load the correct image and set the pixel format from the image file, that is appropriate for the current device. @n
111 * Currently supported image formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
115 * @return A Bitmap instance generated from the specified file.
116 * @param[in] imagePath The relative path starting from the density directory "/res/screen-density-XXX/", @n
117 * where A and B represents the width and height of the screen of the supported device models, respectively
118 * @exception E_SUCCESS The method was successful.
119 * @exception E_INVALID_ARG A specified input parameter is invalid.
120 * @exception E_UNSUPPORTED_FORMAT The image file format is not supported.
121 * @exception E_OUT_OF_MEMORY Insufficient memory.
122 * @exception E_FILE_NOT_FOUND The specified file could not be found.
123 * @exception E_SYSTEM A system error occurred.
125 Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imagePath);
127 static void Reinitialize(void);
130 * Gets the AppResoruce instance pointer.
133 * @return An AppResoruce instance pointer, if successful @n
134 * @c null, if it fails
136 static _AppResourceImpl* GetInstance(void);
138 static AppResource* GetInstanceN(AppResourceBy type, const Tizen::Base::String& value = L"");
139 static _IAppResourceBitmap* Get_IAppResourceBitmapN(AppResourceBy type, const Tizen::Base::String& value = L"");
141 static void ReinitializeAll(void);
142 static result ReleaseInstance(const Tizen::Base::String& key);
144 static Tizen::Graphics::Bitmap* GetNonScalingBitmapN(const Tizen::Base::String& imagePath);
147 * This is the default constructor for this class.
151 _AppResourceImpl(void);
154 * This is the copy constructor for this class.
158 _AppResourceImpl(const _AppResourceImpl& source);
161 * This is the assignment operator for this class.
163 _AppResourceImpl& operator =(const _AppResourceImpl& source);
165 static void InitSingleton(void);
166 static void DestroySingleton(void);
169 _AppResourceString* __p_AppResourceString;
170 _IAppResourceBitmap* __p_IAppResourceBitmap;
172 AppResourceBy __type;
173 Tizen::Base::String __value;
175 static Tizen::Base::Collection::HashMap* __pContainer;
176 static Tizen::Base::Runtime::Mutex* __pLock;
177 }; // _AppResourceImpl
181 #endif // _FAPP_INTERNAL_APP_RESOURCE_IMPL_H_