2 * Copyright (c) 2014 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.
21 #include "bitmap-loader-impl.h"
22 #include "image-loaders/image-loader.h"
29 IntrusivePtr<BitmapLoader> BitmapLoader::New(const std::string& url,
31 FittingMode::Type fittingMode,
32 SamplingMode::Type samplingMode,
33 bool orientationCorrection)
35 IntrusivePtr<BitmapLoader> internal = new BitmapLoader( url, size, fittingMode, samplingMode, orientationCorrection );
39 BitmapLoader::BitmapLoader(const std::string& url,
41 FittingMode::Type fittingMode,
42 SamplingMode::Type samplingMode,
43 bool orientationCorrection)
44 : mResourceType( size, fittingMode, samplingMode, orientationCorrection ),
50 BitmapLoader::~BitmapLoader()
54 void BitmapLoader::Load()
56 IntrusivePtr<Dali::RefObject> resource = TizenPlatform::ImageLoader::LoadResourceSynchronously( mResourceType, mUrl );
60 Integration::Bitmap* bitmap = static_cast<Integration::Bitmap*>(resource.Get());
62 // Use bitmap->GetBufferOwnership() to transfer the buffer ownership to pixelData.
63 // The destroy of bitmap will not release the buffer, instead, the pixelData is responsible for releasing when its reference count falls to zero.
64 mPixelData = Dali::PixelData::New( bitmap->GetBufferOwnership(),
65 bitmap->GetBufferSize(),
66 bitmap->GetImageWidth(),
67 bitmap->GetImageHeight(),
68 bitmap->GetPixelFormat(),
69 Dali::PixelData::FREE);
73 bool BitmapLoader::IsLoaded()
75 return mPixelData ? true : false ;
78 const std::string& BitmapLoader::GetUrl() const
83 Dali::PixelData BitmapLoader::GetPixelData() const
88 } // namespace Internal