}
BitmapLoader::BitmapLoader(const std::string& url,
- ImageDimensions size,
- FittingMode::Type fittingMode,
- SamplingMode::Type samplingMode,
- bool orientationCorrection)
+ ImageDimensions size,
+ FittingMode::Type fittingMode,
+ SamplingMode::Type samplingMode,
+ bool orientationCorrection)
: mResourceType( size, fittingMode, samplingMode, orientationCorrection ),
- mBitmap(NULL),
- mUrl(url),
- mIsLoaded( false )
+ mPixelData(),
+ mUrl(url)
{
}
{
IntrusivePtr<Dali::RefObject> resource = TizenPlatform::ImageLoader::LoadResourceSynchronously( mResourceType, mUrl );
- mBitmap = static_cast<Integration::Bitmap*>(resource.Get());
- mIsLoaded = true;
-}
-
-bool BitmapLoader::IsLoaded()
-{
- return mIsLoaded;
-}
-
-unsigned char* BitmapLoader::GetPixelData() const
-{
- if( mIsLoaded )
+ if( resource )
{
- return mBitmap->GetBuffer();
+ Integration::Bitmap* bitmap = static_cast<Integration::Bitmap*>(resource.Get());
+
+ // Use bitmap->GetBufferOwnership() to transfer the buffer ownership to pixelData.
+ // The destroy of bitmap will not release the buffer, instead, the pixelData is responsible for releasing when its reference count falls to zero.
+ mPixelData = PixelData::New( bitmap->GetBufferOwnership(),
+ bitmap->GetImageWidth(),
+ bitmap->GetImageHeight(),
+ bitmap->GetPixelFormat(),
+ PixelData::FREE);
}
-
- return NULL;
}
-unsigned int BitmapLoader::GetImageHeight() const
+bool BitmapLoader::IsLoaded()
{
- if( mIsLoaded )
- {
- return mBitmap->GetImageHeight();
- }
-
- return 0u;
+ return mPixelData ? true : false ;
}
-unsigned int BitmapLoader::GetImageWidth() const
+const std::string& BitmapLoader::GetUrl() const
{
- if( mIsLoaded )
- {
- return mBitmap->GetImageWidth();
- }
-
- return 0u;
+ return mUrl;
}
-Pixel::Format BitmapLoader::GetPixelFormat() const
+PixelDataPtr BitmapLoader::GetPixelData() const
{
- if( mIsLoaded )
- {
- return mBitmap->GetPixelFormat();
- }
-
- return Pixel::RGBA8888;
+ return mPixelData;
}
} // namespace Internal