Fixed some README comments
[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 #include "bitmap-loader-impl.h"
18 #include <dali/integration-api/resource-types.h>
19 #include <dali/integration-api/resource-cache.h>
20 #include "image-loaders/image-loader.h"
21
22 #include <string>
23
24 namespace Dali
25 {
26 namespace Internal
27 {
28
29 IntrusivePtr<BitmapLoader> BitmapLoader::New(const std::string& filename)
30 {
31   IntrusivePtr<BitmapLoader> internal = new BitmapLoader();
32   internal->Initialize(filename);
33   return internal;
34 }
35
36 BitmapLoader::BitmapLoader()
37 : mBitmap(NULL)
38 {
39 }
40
41 BitmapLoader::~BitmapLoader()
42 {
43 }
44
45 void BitmapLoader::Initialize(const std::string& filename)
46 {
47   ImageAttributes attributes;
48   Integration::BitmapResourceType bitmapResourceType( attributes );
49   Integration::ResourcePointer resource = SlpPlatform::ImageLoader::LoadResourceSynchronously( bitmapResourceType, filename );
50
51   mBitmap = static_cast<Integration::Bitmap*>(resource.Get());
52 }
53
54 unsigned char* BitmapLoader::GetPixelData() const
55 {
56   return mBitmap->GetBuffer();
57 }
58
59 unsigned int BitmapLoader::GetImageHeight() const
60 {
61   return mBitmap->GetImageHeight();
62 }
63
64 unsigned int BitmapLoader::GetImageWidth() const
65 {
66   return mBitmap->GetImageWidth();
67 }
68
69 unsigned int BitmapLoader::GetBufferStride() const
70 {
71   return mBitmap->GetPackedPixelsProfile()->GetBufferStride();
72 }
73
74 Pixel::Format BitmapLoader::GetPixelFormat() const
75 {
76   return mBitmap->GetPixelFormat();
77 }
78
79 } // namespace Internal
80 } // namespace Dali