2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FApp_AppResourceImpl.h
20 * @brief This is the header file of the _AppResourceImpl class.
23 #ifndef _FAPP_INTERNAL_APP_RESOURCE_IMPL_H_
24 #define _FAPP_INTERNAL_APP_RESOURCE_IMPL_H_
26 #include <FBaseObject.h>
27 #include <FBaseString.h>
29 #include <FGrpBitmapCommon.h>
31 namespace Tizen { namespace Base { namespace Collection { class HashMap; } } }
32 namespace Tizen { namespace Graphics { class Bitmap; } }
34 namespace Tizen { namespace App
38 class _AppResourceString;
39 class _IAppResourceBitmap;
44 APP_RESOURCE_BY_APP_ID,
45 APP_RESOURCE_BY_LIBRARY_NAME,
49 class _AppResourceImpl
50 : public Tizen::Base::Object
54 * This is the destructor for this class.
58 virtual ~_AppResourceImpl(void);
61 * Gets the string at the specified resource ID.
64 * @return An error code
65 * @param[in] resourceId The resource ID describing the String resource
66 * @param[out] loadedString The string obtained from the loaded application resource
67 * @exception E_SUCCESS The method was successful.
68 * @exception E_FAILURE The argument passed is not found.
69 * @exception E_INVALID_ARG The argument passed to a method contains an invalid resource ID.
71 result GetString(const Tizen::Base::String& resourceId, Tizen::Base::String& loadedString);
74 * Gets the Bitmap at the specified path. @n
75 * This method interprets the given resource path and reads the best matching image file for the current device resolution. @n
76 * To load bitmap image from a file, you give the name of file as the input parameter not the file path (Ex: "img.png").
77 * Then, the system will first look for the image file in the folder specific to the current device resolution such as
78 * '320x480' and if the file does not exist, it will then search the folder that corresponds to the current screen density,
79 * such as 'ScreenDensity-Middle'. After searching density folder, all other density folders are searched in the order high to low.
80 * Currently supported image formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
84 * @return A Bitmap instance generated from the specified file
85 * @param[in] imagePath The relative path starting from the directory "/res/screen-density-XXX/", @n
86 * where A and B represents the screen width and height of the supported device models, respectively.
87 * @param[in] pixelFormat The pixel format of the resulting bitmap
88 * @exception E_SUCCESS The method was successful.
89 * @exception E_INVALID_ARG A specified input parameter is invalid.
90 * @exception E_UNSUPPORTED_FORMAT The image file format or specified pixel format is not supported.
91 * @exception E_OUT_OF_MEMORY Insufficient memory.
92 * @exception E_FILE_NOT_FOUND The specified file could not be found.
93 * @exception E_SYSTEM A system error occurred.
95 Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat);
98 * Gets the Bitmap at the specified path. @n
99 * This method interprets the given resource path and reads the best matching image file for the current device resolution. @n
100 * To load bitmap image from a file, you give the name of file as the input parameter not the file path (Ex: "img.png").
101 * Then, the system will first look for the image file in the folder specific to the current device resolution such as
102 * '320x480' and if the file does not exist, it will then search the folder that corresponds to the current screen density,
103 * such as 'ScreenDensity-Middle'. After searching density folder, all other density folders are searched in the order high to low.
104 * Currently supported image formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
106 * In this method, the system decides the proper pixel format and whether to use chroma key composition to enable transparency. @n
107 * If the input image file has the alpha channel, the pixel format is set to Tizen::Graphics::BITMAP_PIXEL_FORMAT_ARGB8888.
108 * 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
109 * Typically, a WVGA Tizen device would support alpha channel, while WQVGA device would support bitmap with masking color, to support transparency.
110 * 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'.
111 * 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
112 * Currently supported image formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
116 * @return A Bitmap instance generated from the specified file.
117 * @param[in] imagePath The relative path starting from the density directory "/res/screen-density-XXX/", @n
118 * where A and B represents the width and height of the screen of the supported device models, respectively
119 * @exception E_SUCCESS The method was successful.
120 * @exception E_INVALID_ARG A specified input parameter is invalid.
121 * @exception E_UNSUPPORTED_FORMAT The image file format is not supported.
122 * @exception E_OUT_OF_MEMORY Insufficient memory.
123 * @exception E_FILE_NOT_FOUND The specified file could not be found.
124 * @exception E_SYSTEM A system error occurred.
126 Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imagePath);
128 static void Reinitialize(void);
131 * Gets the AppResoruce instance pointer.
134 * @return An AppResoruce instance pointer, if successful @n
135 * @c null, if it fails
137 static _AppResourceImpl* GetInstance(void);
139 static AppResource* GetInstanceN(AppResourceBy type, const Tizen::Base::String& value = L"");
140 static _IAppResourceBitmap* Get_IAppResourceBitmapN(AppResourceBy type, const Tizen::Base::String& value = L"");
142 static void ReinitializeAll(void);
143 static result ReleaseInstance(const Tizen::Base::String& key);
145 static Tizen::Graphics::Bitmap* GetNonScalingBitmapN(const Tizen::Base::String& imagePath);
148 * This is the default constructor for this class.
152 _AppResourceImpl(void);
155 * This is the copy constructor for this class.
159 _AppResourceImpl(const _AppResourceImpl& source);
162 * This is the assignment operator for this class.
164 _AppResourceImpl& operator =(const _AppResourceImpl& source);
167 _AppResourceString* __p_AppResourceString;
168 _IAppResourceBitmap* __p_IAppResourceBitmap;
170 AppResourceBy __type;
171 Tizen::Base::String __value;
173 static Tizen::Base::Collection::HashMap* __pContainer;
175 }; // _AppResourceImpl
179 #endif // _FAPP_INTERNAL_APP_RESOURCE_IMPL_H_