Revert "[Tizen] Fix build errors in adaptor-uv by ecore wayland"
[platform/core/uifw/dali-adaptor.git] / adaptors / common / bitmap-loader-impl.cpp
index 7aaeb7d..9cef7ee 100644 (file)
 // EXTERNAL INCLUDES
 #include <string>
 
-#include <dali/integration-api/resource-types.h>
-#include <dali/integration-api/resource-cache.h>
-
 // INTERNAL INCLUDES
+#include "image-loading.h"
 #include "bitmap-loader-impl.h"
-#include "image-loaders/image-loader.h"
 
 namespace Dali
 {
 namespace Internal
 {
 
-IntrusivePtr<BitmapLoader> BitmapLoader::New(const std::string& filename)
+IntrusivePtr<BitmapLoader> BitmapLoader::New(const std::string& url,
+                                             ImageDimensions size,
+                                             FittingMode::Type fittingMode,
+                                             SamplingMode::Type samplingMode,
+                                             bool orientationCorrection)
 {
-  IntrusivePtr<BitmapLoader> internal = new BitmapLoader();
-  internal->Initialize(filename);
+  IntrusivePtr<BitmapLoader> internal = new BitmapLoader( url, size, fittingMode, samplingMode, orientationCorrection );
   return internal;
 }
 
-BitmapLoader::BitmapLoader()
-: mBitmap(NULL)
+BitmapLoader::BitmapLoader(const std::string& url,
+                           ImageDimensions size,
+                           FittingMode::Type fittingMode,
+                           SamplingMode::Type samplingMode,
+                           bool orientationCorrection )
+: mPixelData(),
+  mUrl(url),
+  mSize( size ),
+  mFittingMode( fittingMode ),
+  mSamplingMode( samplingMode ),
+  mOrientationCorrection( orientationCorrection )
 {
 }
 
@@ -45,38 +54,24 @@ BitmapLoader::~BitmapLoader()
 {
 }
 
-void BitmapLoader::Initialize(const std::string& filename)
-{
-  ImageAttributes attributes;
-  Integration::BitmapResourceType bitmapResourceType( attributes );
-  Integration::ResourcePointer resource = TizenPlatform::ImageLoader::LoadResourceSynchronously( bitmapResourceType, filename );
-
-  mBitmap = static_cast<Integration::Bitmap*>(resource.Get());
-}
-
-unsigned char* BitmapLoader::GetPixelData() const
-{
-  return mBitmap->GetBuffer();
-}
-
-unsigned int BitmapLoader::GetImageHeight() const
+void BitmapLoader::Load()
 {
-  return mBitmap->GetImageHeight();
+  mPixelData = Dali::LoadImageFromFile( mUrl, mSize, mFittingMode, mSamplingMode, mOrientationCorrection );
 }
 
-unsigned int BitmapLoader::GetImageWidth() const
+bool BitmapLoader::IsLoaded()
 {
-  return mBitmap->GetImageWidth();
+  return mPixelData ? true : false ;
 }
 
-unsigned int BitmapLoader::GetBufferStride() const
+const std::string& BitmapLoader::GetUrl() const
 {
-  return mBitmap->GetPackedPixelsProfile()->GetBufferStride();
+  return mUrl;
 }
 
-Pixel::Format BitmapLoader::GetPixelFormat() const
+Dali::PixelData BitmapLoader::GetPixelData() const
 {
-  return mBitmap->GetPixelFormat();
+  return mPixelData;
 }
 
 } // namespace Internal