Merge "Change "SLP" to "Tizen"" into tizen
[platform/core/uifw/dali-adaptor.git] / adaptors / common / bitmap-loader-impl.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 // EXTERNAL INCLUDES
18 #include <string>
19
20 #include <dali/integration-api/resource-types.h>
21 #include <dali/integration-api/resource-cache.h>
22
23 // INTERNAL INCLUDES
24 #include "bitmap-loader-impl.h"
25 #include "image-loaders/image-loader.h"
26
27 namespace Dali
28 {
29 namespace Internal
30 {
31
32 IntrusivePtr<BitmapLoader> BitmapLoader::New(const std::string& filename)
33 {
34   IntrusivePtr<BitmapLoader> internal = new BitmapLoader();
35   internal->Initialize(filename);
36   return internal;
37 }
38
39 BitmapLoader::BitmapLoader()
40 : mBitmap(NULL)
41 {
42 }
43
44 BitmapLoader::~BitmapLoader()
45 {
46 }
47
48 void BitmapLoader::Initialize(const std::string& filename)
49 {
50   ImageAttributes attributes;
51   Integration::BitmapResourceType bitmapResourceType( attributes );
52   Integration::ResourcePointer resource = TizenPlatform::ImageLoader::LoadResourceSynchronously( bitmapResourceType, filename );
53
54   mBitmap = static_cast<Integration::Bitmap*>(resource.Get());
55 }
56
57 unsigned char* BitmapLoader::GetPixelData() const
58 {
59   return mBitmap->GetBuffer();
60 }
61
62 unsigned int BitmapLoader::GetImageHeight() const
63 {
64   return mBitmap->GetImageHeight();
65 }
66
67 unsigned int BitmapLoader::GetImageWidth() const
68 {
69   return mBitmap->GetImageWidth();
70 }
71
72 unsigned int BitmapLoader::GetBufferStride() const
73 {
74   return mBitmap->GetPackedPixelsProfile()->GetBufferStride();
75 }
76
77 Pixel::Format BitmapLoader::GetPixelFormat() const
78 {
79   return mBitmap->GetPixelFormat();
80 }
81
82 } // namespace Internal
83 } // namespace Dali