2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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 StResourceManager.cpp
19 * @brief This is the implementation file for ResourceManager class.
23 #include "StResourceManager.h"
25 using namespace Tizen::App;
26 using namespace Tizen::Base;
27 using namespace Tizen::Graphics;
28 using namespace Tizen::Media;
29 using namespace Tizen::Ui;
32 ResourceManager::GetBitmapN(const Tizen::Base::String& imagePath)
34 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
35 if (pAppResource == null)
37 AppLogDebug("[%s] Unable to get app resource.");
41 return pAppResource->GetBitmapN(imagePath);
45 ResourceManager::GetApplicationBitmapN(const String& imageAbsolutePath)
48 Bitmap* pBitmap = null;
49 Image* pImage = new (std::nothrow) Image();
52 fullname.Append(imageAbsolutePath);
56 r = pImage->Construct();
57 TryCatch(r == E_SUCCESS, , "Image Construct Failed = (%s)\n", GetErrorMessage(r));
58 if (fullname.EndsWith(L"jpg") || fullname.EndsWith(L"JPG") || fullname.EndsWith(L"jpeg") || fullname.EndsWith(L"JPEG"))
60 pBitmap = pImage->DecodeN(fullname, BITMAP_PIXEL_FORMAT_RGB565);
62 else if (fullname.EndsWith(L"bmp") || fullname.EndsWith(L"BMP"))
64 pBitmap = pImage->DecodeN(fullname, BITMAP_PIXEL_FORMAT_RGB565);
66 else if (fullname.EndsWith(L"png") || fullname.EndsWith(L"PNG") || fullname.EndsWith(L"wbmp") || fullname.EndsWith(L"WBMP"))
68 pBitmap = pImage->DecodeN(fullname, BITMAP_PIXEL_FORMAT_ARGB8888);
70 else if (fullname.EndsWith(L"gif") || fullname.EndsWith(L"GIF"))
72 pBitmap = pImage->DecodeN(fullname, BITMAP_PIXEL_FORMAT_RGB565);
75 TryCatch(pBitmap != null, , "not found image path or not enough memory %ls error = %s", fullname.GetPointer()
76 , GetErrorMessage(GetLastResult()));
92 ResourceManager::GetString(const Tizen::Base::String& stringId)
95 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
97 if (pAppResource == null)
99 AppLogDebug("Unable to get resource instance.");
103 pAppResource->GetString(stringId, str);