Cleanup for removal of ImageAttributes from public API 88/37588/8
authorAndrew Cox <andrew.cox@partner.samsung.com>
Tue, 31 Mar 2015 13:02:19 +0000 (14:02 +0100)
committerAndrew Cox <andrew.cox@partner.samsung.com>
Mon, 20 Apr 2015 11:06:55 +0000 (12:06 +0100)
This is cleanup after core patch:
  https://review.tizen.org/gerrit/#/c/37213

Change-Id: Idf8c2bad2150cd253e9c70c4b3d1b55b26713f9d
Signed-off-by: Andrew Cox <andrew.cox@partner.samsung.com>
33 files changed:
adaptors/common/bitmap-loader-impl.cpp
automated-tests/src/dali-adaptor-internal/image-loaders.cpp
automated-tests/src/dali-adaptor-internal/image-loaders.h
automated-tests/src/dali-adaptor-internal/utc-Dali-ImageOperations.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.h
automated-tests/src/dali-platform-abstraction/utc-image-loading-cancel-all-loads.cpp
automated-tests/src/dali-platform-abstraction/utc-image-loading-cancel-some-loads.cpp
automated-tests/src/dali-platform-abstraction/utc-image-loading-common.cpp
automated-tests/src/dali-platform-abstraction/utc-image-loading-common.h
automated-tests/src/dali-platform-abstraction/utc-image-loading-load-completion.cpp
platform-abstractions/portable/image-operations.cpp
platform-abstractions/portable/image-operations.h
platform-abstractions/tizen/image-loaders/image-loader-input.h [new file with mode: 0644]
platform-abstractions/tizen/image-loaders/image-loader.cpp
platform-abstractions/tizen/image-loaders/image-loader.h
platform-abstractions/tizen/image-loaders/loader-bmp.cpp
platform-abstractions/tizen/image-loaders/loader-bmp.h
platform-abstractions/tizen/image-loaders/loader-gif.cpp
platform-abstractions/tizen/image-loaders/loader-gif.h
platform-abstractions/tizen/image-loaders/loader-ico.cpp
platform-abstractions/tizen/image-loaders/loader-ico.h
platform-abstractions/tizen/image-loaders/loader-jpeg-turbo.cpp
platform-abstractions/tizen/image-loaders/loader-jpeg.cpp
platform-abstractions/tizen/image-loaders/loader-jpeg.h
platform-abstractions/tizen/image-loaders/loader-ktx.cpp
platform-abstractions/tizen/image-loaders/loader-ktx.h
platform-abstractions/tizen/image-loaders/loader-png.cpp
platform-abstractions/tizen/image-loaders/loader-png.h
platform-abstractions/tizen/image-loaders/loader-wbmp.cpp
platform-abstractions/tizen/image-loaders/loader-wbmp.h
platform-abstractions/tizen/tizen-platform-abstraction.cpp
platform-abstractions/tizen/tizen-platform-abstraction.h

index 7aaeb7d..69505df 100644 (file)
@@ -47,8 +47,8 @@ BitmapLoader::~BitmapLoader()
 
 void BitmapLoader::Initialize(const std::string& filename)
 {
-  ImageAttributes attributes;
-  Integration::BitmapResourceType bitmapResourceType( attributes );
+  // Load with default scaling and orientation correction:
+  Integration::BitmapResourceType bitmapResourceType;
   Integration::ResourcePointer resource = TizenPlatform::ImageLoader::LoadResourceSynchronously( bitmapResourceType, filename );
 
   mBitmap = static_cast<Integration::Bitmap*>(resource.Get());
index 94fdb8a..093a33c 100644 (file)
@@ -101,8 +101,8 @@ void TestImageLoading( const ImageDetails& image, const LoadFunctions& functions
   // Check the header file.
 
   unsigned int width(0), height(0);
-  Dali::ImageAttributes attributes;
-  DALI_TEST_CHECK( functions.header( fp, attributes, width, height ) );
+  const Dali::TizenPlatform::ImageLoader::Input input( fp );
+  DALI_TEST_CHECK( functions.header( input, width, height ) );
 
   DALI_TEST_EQUALS( width,  image.reportedWidth,  TEST_LOCATION );
   DALI_TEST_EQUALS( height, image.reportedHeight, TEST_LOCATION );
@@ -116,9 +116,9 @@ void TestImageLoading( const ImageDetails& image, const LoadFunctions& functions
 
 
   // Load Bitmap and check its return values.
-  DALI_TEST_CHECK( functions.loader( fp, *bitmap, attributes, StubImageLoaderClient() ) );
-  DALI_TEST_EQUALS( image.width,  attributes.GetWidth(),  TEST_LOCATION );
-  DALI_TEST_EQUALS( image.height, attributes.GetHeight(), TEST_LOCATION );
+  DALI_TEST_CHECK( functions.loader( StubImageLoaderClient(), input, *bitmap ) );
+  DALI_TEST_EQUALS( image.width,  bitmap->GetImageWidth(),  TEST_LOCATION );
+  DALI_TEST_EQUALS( image.height, bitmap->GetImageHeight(), TEST_LOCATION );
 
   // Compare buffer generated with reference buffer.
   Dali::PixelBuffer* bufferPtr( bitmapPtr->GetBuffer() );
@@ -141,13 +141,13 @@ void DumpImageBufferToTempFile( std::string filename, std::string targetFilename
 
   Dali::Integration::Bitmap* bitmap = Dali::Integration::Bitmap::New( Dali::Integration::Bitmap::BITMAP_2D_PACKED_PIXELS,  ResourcePolicy::RETAIN );
   Dali::Integration::BitmapPtr bitmapPtr( bitmap );
-  Dali::ImageAttributes attributes;
+  const Dali::TizenPlatform::ImageLoader::Input input( fp );
 
-  DALI_TEST_CHECK( functions.loader( fp, *bitmap, attributes, StubImageLoaderClient() ) );
+  DALI_TEST_CHECK( functions.loader( StubImageLoaderClient(), input, *bitmap ) );
 
   Dali::PixelBuffer* bufferPtr( bitmapPtr->GetBuffer() );
 
   FILE* writeFp = fopen( targetFilename.c_str(), "wb" );
   AutoCloseFile autoCloseWrite( writeFp );
-  fwrite( bufferPtr, sizeof( Dali::PixelBuffer ), attributes.GetWidth() * attributes.GetHeight(), writeFp );
+  fwrite( bufferPtr, 1, bitmap->GetBufferSize(), writeFp );
 }
index 3cf23ae..ffbb2b3 100644 (file)
@@ -21,6 +21,7 @@
 #include <dali/dali.h>
 #include <dali/integration-api/bitmap.h>
 #include "platform-abstractions/tizen/resource-loader/resource-loading-client.h"
+#include "platform-abstractions/tizen/image-loaders/image-loader-input.h"
 
 // Simple structure to close the file when finished with it.
 struct AutoCloseFile
@@ -82,8 +83,8 @@ private:
  */
 struct LoadFunctions
 {
-  typedef bool (*LoadBitmapFunction)(FILE*, Dali::Integration::Bitmap&, Dali::ImageAttributes&, const Dali::TizenPlatform::ResourceLoadingClient& client);
-  typedef bool (*LoadBitmapHeaderFunction)(FILE*, const Dali::ImageAttributes& attrs, unsigned int& width, unsigned int& height );
+  typedef bool (*LoadBitmapFunction)( const Dali::TizenPlatform::ResourceLoadingClient& client, const Dali::TizenPlatform::ImageLoader::Input& input, Dali::Integration::Bitmap& );
+  typedef bool (*LoadBitmapHeaderFunction)( const Dali::TizenPlatform::ImageLoader::Input& input, unsigned int& width, unsigned int& height );
 
   LoadFunctions( LoadBitmapHeaderFunction _header, LoadBitmapFunction _loader );
   LoadBitmapHeaderFunction header;
index 6643df7..2754c2f 100644 (file)
@@ -354,15 +354,15 @@ void TestDownscaledBitmapHasRightDimensionsAndFormat(
     uint32_t expectedDimension,
     const char * const location )
 {
-  ImageAttributes attributes;
-  attributes.SetScalingMode( ImageAttributes::ShrinkToFit );
-  attributes.SetFilterMode( ImageAttributes::Box );
-  attributes.SetSize( targetDimension, targetDimension );
+  ImageDimensions desired( targetDimension, targetDimension );
+  FittingMode::Type fittingMode( FittingMode::SHRINK_TO_FIT );
+  SamplingMode::Type samplingMode( SamplingMode::BOX );
 
   Integration::BitmapPtr sourceBitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
   sourceBitmap->GetPackedPixelsProfile()->ReserveBuffer( format, sourceDimension, sourceDimension, sourceDimension, sourceDimension );
 
-  Integration::BitmapPtr downScaled = DownscaleBitmap( *sourceBitmap, ImageDimensions( targetDimension, targetDimension ), attributes.GetScalingMode(), attributes.GetFilterMode() );
+  Integration::BitmapPtr downScaled = DownscaleBitmap( *sourceBitmap, desired, fittingMode, samplingMode );
+
   DALI_TEST_EQUALS( downScaled->GetImageWidth(), expectedDimension, location );
   DALI_TEST_EQUALS( downScaled->GetImageHeight(), expectedDimension, location );
   DALI_TEST_EQUALS( downScaled->GetPixelFormat(), format, location );
@@ -1447,9 +1447,9 @@ int UtcDaliImageOperationsPointSampleRGB88InBounds(void)
 /**
  * @brief Test the small int (x,y) tuple.
  */
-int UtcDaliImageOperationsVector2Uint16(void)
+int UtcDaliImageOperationsUint16Pair(void)
 {
-  Vector2Uint16 vec1( 2, 3 );
+  Uint16Pair vec1( 2, 3 );
 
   DALI_TEST_EQUALS( vec1.GetWidth(), 2, TEST_LOCATION );
   DALI_TEST_EQUALS( vec1.GetX(),     2, TEST_LOCATION );
@@ -1457,7 +1457,7 @@ int UtcDaliImageOperationsVector2Uint16(void)
   DALI_TEST_EQUALS( vec1.GetHeight(), 3, TEST_LOCATION );
   DALI_TEST_EQUALS( vec1.GetY(),      3, TEST_LOCATION );
 
-  Vector2Uint16 vec1Copy = vec1;
+  Uint16Pair vec1Copy = vec1;
 
   DALI_TEST_EQUALS( vec1Copy.GetWidth(), 2, TEST_LOCATION );
   DALI_TEST_EQUALS( vec1Copy.GetX(),     2, TEST_LOCATION );
@@ -1465,7 +1465,7 @@ int UtcDaliImageOperationsVector2Uint16(void)
   DALI_TEST_EQUALS( vec1Copy.GetHeight(), 3, TEST_LOCATION );
   DALI_TEST_EQUALS( vec1Copy.GetY(),      3, TEST_LOCATION );
 
-  Vector2Uint16 vec2( 65535u, 65535u );
+  Uint16Pair vec2( 65535u, 65535u );
 
   DALI_TEST_EQUALS( vec2.GetX(), 65535u, TEST_LOCATION );
   DALI_TEST_EQUALS( vec2.GetY(), 65535u, TEST_LOCATION );
index 60de63d..bd8988d 100644 (file)
@@ -64,23 +64,28 @@ void TestPlatformAbstraction::Resume()
   mTrace.PushCall("Resume", "");
 }
 
-void TestPlatformAbstraction::GetClosestImageSize( const std::string& filename,
-                                                   const ImageAttributes& attributes,
-                                                   Vector2& closestSize)
+ImageDimensions TestPlatformAbstraction::GetClosestImageSize( const std::string& filename,
+                                                              ImageDimensions size,
+                                                              FittingMode::Type fittingMode,
+                                                              SamplingMode::Type samplingMode,
+                                                              bool orientationCorrection )
 {
-  closestSize = mClosestSize;
+  ImageDimensions closestSize = ImageDimensions( mClosestSize.x, mClosestSize.y );
   mTrace.PushCall("GetClosestImageSize", "");
+  return closestSize;
 }
 
-void TestPlatformAbstraction::GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
-                                                   const ImageAttributes& attributes,
-                                                   Vector2& closestSize)
+ImageDimensions TestPlatformAbstraction::GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
+                                                   ImageDimensions size,
+                                                   FittingMode::Type fittingMode,
+                                                   SamplingMode::Type samplingMode,
+                                                   bool orientationCorrection )
 {
-  closestSize = mClosestSize;
+  ImageDimensions closestSize = ImageDimensions( mClosestSize.x, mClosestSize.y );
   mTrace.PushCall("GetClosestImageSize", "");
+  return closestSize;
 }
 
-
 /**
  * @copydoc PlatformAbstraction::LoadResource()
  */
index 80e6bd6..47dad97 100644 (file)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <stdint.h>
 #include <cstring>
+#include <dali/public-api/images/image-operations.h>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/set-wrapper.h>
@@ -97,15 +98,24 @@ public:
    */
   virtual void Resume();
 
-  virtual void GetClosestImageSize( const std::string& filename,
-                                    const ImageAttributes& attributes,
-                                    Vector2& closestSize);
-
-  virtual void GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
-                                    const ImageAttributes& attributes,
-                                    Vector2& closestSize);
+  /**
+   * @copydoc PlatformAbstraction::GetClosestImageSize()
+   */
+  virtual ImageDimensions GetClosestImageSize( const std::string& filename,
+                                                 ImageDimensions size,
+                                                 FittingMode::Type fittingMode,
+                                                 SamplingMode::Type samplingMode,
+                                                 bool orientationCorrection );
 
   /**
+   * @copydoc PlatformAbstraction::GetClosestImageSize()
+   */
+  virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
+                                               ImageDimensions size,
+                                               FittingMode::Type fittingMode,
+                                               SamplingMode::Type samplingMode,
+                                               bool orientationCorrection );
+  /**
    * @copydoc PlatformAbstraction::LoadResource()
    */
   virtual void LoadResource(const Integration::ResourceRequest& request);
index 037fb7c..0c6d007 100644 (file)
@@ -55,7 +55,8 @@ int UtcDaliCancelAllLoads(void)
     // Issue load requests for a batch of images:
     for( unsigned validImage = 0; validImage < NUM_VALID_IMAGES; ++validImage )
     {
-      const BitmapResourceType bitmapResourceType( gCancelAttributes[ loadsLaunched % gCancelAttributes.size() ] );
+      const ImageAttributes & loadParams = gCancelAttributes[ loadsLaunched % gCancelAttributes.size() ];
+      const BitmapResourceType bitmapResourceType( loadParams.first, loadParams.second.first, loadParams.second.second.first, loadParams.second.second.second );
       const ResourceId resourceId = loadGroup * NUM_VALID_IMAGES + validImage + 1;
       gAbstraction->LoadResource( ResourceRequest( resourceId, bitmapResourceType, VALID_IMAGES[validImage], priority ) );
       loadsLaunched += 1;
index 0a89566..ed58204 100644 (file)
@@ -54,7 +54,8 @@ int UtcDaliCancelSomeLoads(void)
     // Issue load requests for a batch of images:
     for( unsigned validImage = 0; validImage < NUM_VALID_IMAGES; ++validImage )
     {
-      const BitmapResourceType bitmapResourceType( gCancelAttributes[ loadsLaunched % gCancelAttributes.size() ] );
+      const ImageAttributes & loadParams = gCancelAttributes[ loadsLaunched % gCancelAttributes.size() ];
+      const BitmapResourceType bitmapResourceType( loadParams.first, loadParams.second.first, loadParams.second.second.first, loadParams.second.second.second );
       const ResourceId resourceId = loadGroup * NUM_VALID_IMAGES + validImage + 1;
       gAbstraction->LoadResource( ResourceRequest( resourceId, bitmapResourceType, VALID_IMAGES[validImage], priority ) );
       loadsLaunched += 1;
index 181ff67..d53c0fb 100644 (file)
@@ -31,54 +31,55 @@ void utc_dali_loading_startup(void)
   // Setup some ImageAttributes to engage post-processing stages:
 
   ImageAttributes scaleToFillAttributes;
-  scaleToFillAttributes.SetScalingMode( ImageAttributes::ScaleToFill );
-  scaleToFillAttributes.SetSize( 160, 120 );
+  scaleToFillAttributes.second.first = FittingMode::SCALE_TO_FILL;
+  scaleToFillAttributes.first = ImageDimensions( 160, 120 );
   gCancelAttributes.push_back( scaleToFillAttributes );
 
   // Hit the derived dimensions code:
   ImageAttributes scaleToFillAttributesDeriveWidth = scaleToFillAttributes;
-  scaleToFillAttributesDeriveWidth.SetSize( 0, 120 );
+  scaleToFillAttributesDeriveWidth.first = ImageDimensions( 0, 120 );
   gCancelAttributes.push_back( scaleToFillAttributesDeriveWidth );
 
   ImageAttributes scaleToFillAttributesDeriveHeight = scaleToFillAttributes;
-  scaleToFillAttributesDeriveHeight.SetSize( 160, 0 );
+  scaleToFillAttributesDeriveHeight.first = ImageDimensions( 160, 0 );
   gCancelAttributes.push_back( scaleToFillAttributesDeriveHeight );
 
   // Try to push a tall crop:
   ImageAttributes scaleToFillAttributesTall = scaleToFillAttributes;
-  scaleToFillAttributesTall.SetSize( 160, 480 );
+  scaleToFillAttributesTall.first = ImageDimensions( 160, 480 );
   ImageAttributes scaleToFillAttributesTall2 = scaleToFillAttributes;
-  scaleToFillAttributesTall2.SetSize( 160, 509 );
+  scaleToFillAttributesTall2.first = ImageDimensions( 160, 509 );
   ImageAttributes scaleToFillAttributesTall3 = scaleToFillAttributes;
-  scaleToFillAttributesTall3.SetSize( 37, 251 );
+  scaleToFillAttributesTall3.first = ImageDimensions( 37, 251 );
   gCancelAttributes.push_back( scaleToFillAttributesTall );
   gCancelAttributes.push_back( scaleToFillAttributesTall2 );
   gCancelAttributes.push_back( scaleToFillAttributesTall3 );
 
   // Try to push a wide crop:
   ImageAttributes scaleToFillAttributesWide = scaleToFillAttributes;
-  scaleToFillAttributesWide.SetSize( 320, 60 );
+  scaleToFillAttributesWide.first = ImageDimensions( 320, 60 );
   ImageAttributes scaleToFillAttributesWide2 = scaleToFillAttributes;
-  scaleToFillAttributesWide2.SetSize( 317, 60 );
+  scaleToFillAttributesWide2.first = ImageDimensions( 317, 60 );
   ImageAttributes scaleToFillAttributesWide3 = scaleToFillAttributes;
-  scaleToFillAttributesWide3.SetSize( 317, 53 );
+  scaleToFillAttributesWide3.first = ImageDimensions( 317, 53 );
   gCancelAttributes.push_back( scaleToFillAttributesWide );
   gCancelAttributes.push_back( scaleToFillAttributesWide2 );
   gCancelAttributes.push_back( scaleToFillAttributesWide3 );
 
   ImageAttributes shrinkToFitAttributes = scaleToFillAttributes;
-  shrinkToFitAttributes.SetScalingMode( ImageAttributes::ShrinkToFit );
+  shrinkToFitAttributes.second.first = FittingMode::SHRINK_TO_FIT;
   gCancelAttributes.push_back( shrinkToFitAttributes );
 
   ImageAttributes fitWidthAttributes = scaleToFillAttributes;
-  fitWidthAttributes.SetScalingMode( ImageAttributes::FitWidth );
+  fitWidthAttributes.second.first = FittingMode::FIT_WIDTH;
   gCancelAttributes.push_back( fitWidthAttributes );
 
   ImageAttributes fitHeightAttributes = scaleToFillAttributes;
-  fitHeightAttributes.SetScalingMode( ImageAttributes::FitHeight );
+  fitHeightAttributes.second.first = FittingMode::FIT_HEIGHT;
   gCancelAttributes.push_back( fitHeightAttributes );
 
   ///@ToDo: Add attribute variants for all scale modes.
+  ///@ToDo: Add attribute variants for all filter modes.
 
   // Pad the array to a prime number to mitigate any accidental periodic
   // patterns in which image file has which attributes applied to its load:
index 41edfd8..4bec44b 100644 (file)
@@ -78,6 +78,7 @@ double GetTimeMilliseconds( Integration::PlatformAbstraction& abstraction )
 extern Integration::PlatformAbstraction * gAbstraction;
 
 /** A variety of ImageAttributes to reach different code paths that have embedded code paths. */
+typedef std::pair<ImageDimensions, std::pair<FittingMode::Type, std::pair<SamplingMode::Type, bool> > > ImageAttributes;
 extern std::vector<ImageAttributes> gCancelAttributes;
 
 
index 65014b6..dc5ecf0 100644 (file)
@@ -36,8 +36,7 @@ int UtcDaliLoadCompletion(void)
 
   // Start a bunch of loads that should work:
 
-  const Dali::ImageAttributes attributes;
-  const Dali::Integration::BitmapResourceType bitmapResourceType( attributes );
+  Dali::Integration::BitmapResourceType bitmapResourceType;
   Dali::Integration::LoadResourcePriority priority = Dali::Integration::LoadPriorityNormal;
   unsigned loadsLaunched = 0;
 
@@ -45,14 +44,14 @@ int UtcDaliLoadCompletion(void)
   {
     for( unsigned validImage = 0; validImage < NUM_VALID_IMAGES; ++validImage )
     {
-      gAbstraction->LoadResource( ResourceRequest( loadGroup * NUM_VALID_IMAGES + validImage + 1, bitmapResourceType, VALID_IMAGES[validImage], priority ) );
+      Dali::Integration::ResourceRequest request( loadGroup * NUM_VALID_IMAGES + validImage + 1, bitmapResourceType, VALID_IMAGES[validImage], priority );
+      gAbstraction->LoadResource( request );
     }
     loadsLaunched += NUM_VALID_IMAGES;
   }
 
   // Drain the completed loads:
   Dali::Internal::Platform::ResourceCollector resourceSink;
-  usleep( 1000 * 1000 );
   gAbstraction->GetResources( resourceSink );
   usleep( 500 * 1000 );
   gAbstraction->GetResources( resourceSink );
index 7ccfa55..bf6ff0b 100644 (file)
@@ -20,7 +20,9 @@
 // EXTERNAL INCLUDES
 #include <cstring>
 #include <stddef.h>
+#include <cmath>
 #include <dali/integration-api/debug.h>
+#include <dali/public-api/math/vector2.h>
 
 // INTERNAL INCLUDES
 
@@ -183,37 +185,37 @@ ImageDimensions CalculateDesiredDimensions( unsigned int bitmapWidth, unsigned i
 /**
  * @brief Converts a scaling mode to the definition of which dimensions matter when box filtering as a part of that mode.
  */
-BoxDimensionTest DimensionTestForScalingMode( ImageAttributes::ScalingMode scalingMode )
+BoxDimensionTest DimensionTestForScalingMode( FittingMode::Type fittingMode )
 {
   BoxDimensionTest dimensionTest;
   dimensionTest = BoxDimensionTestEither;
 
-  switch( scalingMode )
+  switch( fittingMode )
   {
     // Shrink to fit attempts to make one or zero dimensions smaller than the
     // desired dimensions and one or two dimensions exactly the same as the desired
     // ones, so as long as one dimension is larger than the desired size, box
     // filtering can continue even if the second dimension is smaller than the
     // desired dimensions:
-    case ImageAttributes::ShrinkToFit:
+    case FittingMode::SHRINK_TO_FIT:
     {
       dimensionTest = BoxDimensionTestEither;
       break;
     }
     // Scale to fill mode keeps both dimensions at least as large as desired:
-    case ImageAttributes::ScaleToFill:
+    case FittingMode::SCALE_TO_FILL:
     {
       dimensionTest = BoxDimensionTestBoth;
       break;
     }
-    // Y dimension is irrelevant when downscaling in FitWidth mode:
-    case ImageAttributes::FitWidth:
+    // Y dimension is irrelevant when downscaling in FIT_WIDTH mode:
+    case FittingMode::FIT_WIDTH:
     {
       dimensionTest = BoxDimensionTestX;
       break;
     }
-    // X Dimension is ignored by definition in FitHeight mode:
-    case ImageAttributes::FitHeight:
+    // X Dimension is ignored by definition in FIT_HEIGHT mode:
+    case FittingMode::FIT_HEIGHT:
     {
       dimensionTest = BoxDimensionTestY;
       break;
@@ -246,7 +248,7 @@ ImageDimensions FitForShrinkToFit( ImageDimensions target, ImageDimensions sourc
 
 /**
  * @brief Work out the dimensions for a uniform scaling of the input to map it
- * into the target while effecting ScaleToFill scaling mode.
+ * into the target while effecting SCALE_TO_FILL scaling mode.
  * @note The output dimensions will need either top and bottom or left and right
  * to be cropped away unless the source was pre-cropped to match the destination
  * aspect ratio.
@@ -270,7 +272,7 @@ ImageDimensions FitForScaleToFill( ImageDimensions target, ImageDimensions sourc
 
 /**
  * @brief Work out the dimensions for a uniform scaling of the input to map it
- * into the target while effecting FitWidth scaling mode.
+ * into the target while effecting FIT_WIDTH scaling mode.
  */
 ImageDimensions FitForFitWidth( ImageDimensions target, ImageDimensions source )
 {
@@ -287,7 +289,7 @@ ImageDimensions FitForFitWidth( ImageDimensions target, ImageDimensions source )
 
 /**
  * @brief Work out the dimensions for a uniform scaling of the input to map it
- * into the target while effecting FitHeight scaling mode.
+ * into the target while effecting FIT_HEIGHT scaling mode.
  */
 ImageDimensions FitForFitHeight( ImageDimensions target, ImageDimensions source )
 {
@@ -307,27 +309,27 @@ ImageDimensions FitForFitHeight( ImageDimensions target, ImageDimensions source
  * @brief Generate the rectangle to use as the target of a pixel sampling pass
  * (e.g., nearest or linear).
  */
-ImageDimensions FitToScalingMode( ImageDimensions requestedSize, ImageDimensions sourceSize, ImageAttributes::ScalingMode scalingMode )
+ImageDimensions FitToScalingMode( ImageDimensions requestedSize, ImageDimensions sourceSize, FittingMode::Type fittingMode )
 {
   ImageDimensions fitDimensions;
-  switch( scalingMode )
+  switch( fittingMode )
   {
-    case ImageAttributes::ShrinkToFit:
+    case FittingMode::SHRINK_TO_FIT:
     {
       fitDimensions = FitForShrinkToFit( requestedSize, sourceSize );
       break;
     }
-    case ImageAttributes::ScaleToFill:
+    case FittingMode::SCALE_TO_FILL:
     {
       fitDimensions = FitForScaleToFill( requestedSize, sourceSize );
       break;
     }
-    case ImageAttributes::FitWidth:
+    case FittingMode::FIT_WIDTH:
     {
       fitDimensions = FitForFitWidth( requestedSize, sourceSize );
       break;
     }
-    case ImageAttributes::FitHeight:
+    case FittingMode::FIT_HEIGHT:
     {
       fitDimensions = FitForFitHeight( requestedSize, sourceSize );
       break;
@@ -368,9 +370,9 @@ BitmapPtr MakeBitmap( const uint8_t * const pixels, Pixel::Format pixelFormat, u
 } // namespace - unnamed
 
 /**
- * @brief Implement ImageAttributes::ScaleTofill scaling mode cropping.
+ * @brief Implement ScaleTofill scaling mode cropping.
  *
- * Implement the cropping required for ImageAttributes::ScaleToFill mode,
+ * Implement the cropping required for SCALE_TO_FILL mode,
  * returning a new bitmap with the aspect ratio specified by the scaling mode.
  * This scaling mode selects the central portion of a source image so any spare
  * pixels off one of either the top or bottom edge need to be removed.
@@ -387,23 +389,21 @@ BitmapPtr MakeBitmap( const uint8_t * const pixels, Pixel::Format pixelFormat, u
  */
 Integration::BitmapPtr CropForScaleToFill( Integration::BitmapPtr bitmap, ImageDimensions desiredDimensions );
 
-BitmapPtr ApplyAttributesToBitmap( BitmapPtr bitmap, const ImageAttributes& requestedAttributes )
+BitmapPtr ApplyAttributesToBitmap( BitmapPtr bitmap, ImageDimensions dimensions, FittingMode::Type fittingMode, SamplingMode::Type samplingMode )
 {
-  ///@ToDo: Optimisation - If Scaling Mode is ScaletoFill, either do cropping here at the front of the pipe, or equivalently modify all scaling functions to take a source rectangle and have the first one to be applied, pull in a subset of source pixels to crop on the fly. That would make every scaling slightly slower but would save the memcpy()s at the end for ScaleToFill.
-
   if( bitmap )
   {
     // Calculate the desired box, accounting for a possible zero component:
-    const ImageDimensions desiredDimensions  = CalculateDesiredDimensions( bitmap->GetImageWidth(), bitmap->GetImageHeight(), requestedAttributes.GetWidth(), requestedAttributes.GetHeight() );
+    const ImageDimensions desiredDimensions  = CalculateDesiredDimensions( bitmap->GetImageWidth(), bitmap->GetImageHeight(), dimensions.GetWidth(), dimensions.GetHeight() );
 
     // If a different size than the raw one has been requested, resize the image
     // maximally using a repeated box filter without making it smaller than the
     // requested size in either dimension:
-    bitmap = DownscaleBitmap( *bitmap, desiredDimensions, requestedAttributes.GetScalingMode(), requestedAttributes.GetFilterMode() );
+    bitmap = DownscaleBitmap( *bitmap, desiredDimensions, fittingMode, samplingMode );
 
     // Cut the bitmap according to the desired width and height so that the
     // resulting bitmap has the same aspect ratio as the desired dimensions:
-    if( bitmap && bitmap->GetPackedPixelsProfile() && requestedAttributes.GetScalingMode() == ImageAttributes::ScaleToFill )
+    if( bitmap && bitmap->GetPackedPixelsProfile() && fittingMode == FittingMode::SCALE_TO_FILL )
     {
       bitmap = CropForScaleToFill( bitmap, desiredDimensions );
     }
@@ -491,8 +491,8 @@ BitmapPtr CropForScaleToFill( BitmapPtr bitmap, ImageDimensions desiredDimension
 
 Integration::BitmapPtr DownscaleBitmap( Integration::Bitmap& bitmap,
                                         ImageDimensions desired,
-                                        ImageAttributes::ScalingMode scalingMode,
-                                        ImageAttributes::FilterMode filterMode )
+                                        FittingMode::Type fittingMode,
+                                        SamplingMode::Type samplingMode )
 {
   // Source dimensions as loaded from resources (e.g. filesystem):
   const unsigned int bitmapWidth  = bitmap.GetImageWidth();
@@ -512,10 +512,10 @@ Integration::BitmapPtr DownscaleBitmap( Integration::Bitmap& bitmap,
 
     // Do the fast power of 2 iterated box filter to get to roughly the right side if the filter mode requests that:
     unsigned int shrunkWidth = -1, shrunkHeight = -1;
-    DownscaleInPlacePow2( bitmap.GetBuffer(), pixelFormat, bitmapWidth, bitmapHeight, desiredWidth, desiredHeight, scalingMode, filterMode, shrunkWidth, shrunkHeight );
+    DownscaleInPlacePow2( bitmap.GetBuffer(), pixelFormat, bitmapWidth, bitmapHeight, desiredWidth, desiredHeight, fittingMode, samplingMode, shrunkWidth, shrunkHeight );
 
     // Work out the dimensions of the downscaled bitmap, given the scaling mode and desired dimensions:
-    const ImageDimensions filteredDimensions = FitToScalingMode( ImageDimensions( desiredWidth, desiredHeight ), ImageDimensions( shrunkWidth, shrunkHeight ), scalingMode );
+    const ImageDimensions filteredDimensions = FitToScalingMode( ImageDimensions( desiredWidth, desiredHeight ), ImageDimensions( shrunkWidth, shrunkHeight ), fittingMode );
     const unsigned int filteredWidth = filteredDimensions.GetWidth();
     const unsigned int filteredHeight = filteredDimensions.GetHeight();
 
@@ -523,13 +523,13 @@ Integration::BitmapPtr DownscaleBitmap( Integration::Bitmap& bitmap,
     bool filtered = false;
     if( filteredWidth < shrunkWidth || filteredHeight < shrunkHeight )
     {
-      if( filterMode == ImageAttributes::Linear || filterMode == ImageAttributes::BoxThenLinear ||
-          filterMode == ImageAttributes::Nearest || filterMode == ImageAttributes::BoxThenNearest )
+      if( samplingMode == SamplingMode::LINEAR || samplingMode == SamplingMode::BOX_THEN_LINEAR ||
+          samplingMode == SamplingMode::NEAREST || samplingMode == SamplingMode::BOX_THEN_NEAREST )
       {
         outputBitmap = MakeEmptyBitmap( pixelFormat, filteredWidth, filteredHeight );
         if( outputBitmap )
         {
-          if( filterMode == ImageAttributes::Linear || filterMode == ImageAttributes::BoxThenLinear )
+          if( samplingMode == SamplingMode::LINEAR || samplingMode == SamplingMode::BOX_THEN_LINEAR )
           {
             LinearSample( bitmap.GetBuffer(), ImageDimensions(shrunkWidth, shrunkHeight), pixelFormat, outputBitmap->GetBuffer(), filteredDimensions );
           }
@@ -848,20 +848,20 @@ void DownscaleInPlacePow2( unsigned char * const pixels,
                            unsigned int inputHeight,
                            unsigned int desiredWidth,
                            unsigned int desiredHeight,
-                           ImageAttributes::ScalingMode scalingMode,
-                           ImageAttributes::FilterMode filterMode,
+                           FittingMode::Type fittingMode,
+                           SamplingMode::Type samplingMode,
                            unsigned& outWidth,
                            unsigned& outHeight )
 {
   outWidth = inputWidth;
   outHeight = inputHeight;
   // Perform power of 2 iterated 4:1 box filtering if the requested filter mode requires it:
-  if( filterMode == ImageAttributes::Box || filterMode == ImageAttributes::BoxThenNearest || filterMode == ImageAttributes::BoxThenLinear )
+  if( samplingMode == SamplingMode::BOX || samplingMode == SamplingMode::BOX_THEN_NEAREST || samplingMode == SamplingMode::BOX_THEN_LINEAR )
   {
     // Check the pixel format is one that is supported:
     if( pixelFormat == Pixel::RGBA8888 || pixelFormat == Pixel::RGB888 || pixelFormat == Pixel::RGB565 || pixelFormat == Pixel::LA88 || pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8 )
     {
-      const BoxDimensionTest dimensionTest = DimensionTestForScalingMode( scalingMode );
+      const BoxDimensionTest dimensionTest = DimensionTestForScalingMode( fittingMode );
 
       if( pixelFormat == Pixel::RGBA8888 )
       {
index a8cd6a0..6d76cfe 100644 (file)
@@ -23,7 +23,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/integration-api/bitmap.h>
-#include <dali/public-api/images/image-attributes.h>
+#include <dali/public-api/images/image-operations.h>
 
 namespace Dali
 {
@@ -44,94 +44,11 @@ enum BoxDimensionTest
 };
 
 /**
- * @brief Simple class for passing around pairs of small ints.
- *
- * These are immutable. If you want to change a value, make a whole new object.
- * @note One of these can be passed in a single 32 bit integer register on
- * common architectures.
- */
-class Vector2Uint16
-{
-public:
-  /**
-   * @brief Default constructor for the (0, 0) vector.
-   */
-  Vector2Uint16() : mData(0) {}
-
-  /**
-   * @brief Constructor taking separate x and y (width and height) parameters.
-   * @param[in] width The width or X dimension of the vector. Make sure it is less than 65536,
-   * @param[in] height The height or Y dimension of the vector. Make sure it is less than 65536,
-   */
-  Vector2Uint16( uint32_t width, uint32_t height )
-  {
-    DALI_ASSERT_DEBUG( width < ( 1u << 16 ) && "Width parameter not representable." );
-    DALI_ASSERT_DEBUG( height < ( 1u << 16 ) && "Height parameter not representable." );
-
-    /* Do equivalent of the code below with one aligned memory access:
-     * mComponents[0] = width;
-     * mComponents[1] = height;
-     * Unit tests make sure this is equivalent.
-     **/
-    mData = (height << 16u) + width;
-  }
-
-  /**
-   * @brief Copy constructor.
-   */
-  Vector2Uint16( const Vector2Uint16& rhs )
-  {
-    mData = rhs.mData;
-  }
-
-  /**
-   * @returns the x dimension stored in this 2-tuple.
-   */
-  uint16_t GetWidth() const
-  {
-    return mComponents[0];
-  }
-
-  /**
-   * @returns the y dimension stored in this 2-tuple.
-   */
-  uint16_t GetHeight() const
-  {
-    return mComponents[1];
-  }
-
-  /**
-   * @returns the x dimension stored in this 2-tuple.
-   */
-  uint16_t GetX()  const
-  {
-    return mComponents[0];
-  }
-
-  /**
-   * @returns the y dimension stored in this 2-tuple.
-   */
-  uint16_t GetY() const
-  {
-    return mComponents[1];
-  }
-
-private:
-  union
-  {
-    // Addressable view of X and Y:
-    uint16_t mComponents[2];
-    // Packed view of X and Y to force alignment and allow a faster copy:
-    uint32_t mData;
-  };
-};
-
-/**
  * @brief The integer dimensions of an image or a region of an image packed into
  *        16 bits per component.
  * @note  This can only be used for images of up to 65535 x 65535 pixels.
   */
-typedef Vector2Uint16 ImageDimensions;
+typedef Uint16Pair ImageDimensions;
 
 /**
  * @defgroup BitmapOperations Bitmap-to-Bitmap Image operations.
@@ -152,13 +69,13 @@ typedef Vector2Uint16 ImageDimensions;
  *         bitmap passed-in, or the original bitmap passed in if the attributes
  *         have no effect.
  */
-Integration::BitmapPtr ApplyAttributesToBitmap( Integration::BitmapPtr bitmap, const ImageAttributes& requestedAttributes );
+Integration::BitmapPtr ApplyAttributesToBitmap( Integration::BitmapPtr bitmap, ImageDimensions dimensions, FittingMode::Type fittingMode = FittingMode::DEFAULT, SamplingMode::Type samplingMode = SamplingMode::DEFAULT );
 
 /**
  * @brief Apply downscaling to a bitmap according to requested attributes.
  * @note The input bitmap pixel buffer may be modified and used as scratch working space for efficiency, so it must be discarded.
  **/
-Integration::BitmapPtr DownscaleBitmap( Integration::Bitmap& bitmap, ImageDimensions desired, ImageAttributes::ScalingMode scalingMode, ImageAttributes::FilterMode filterMode );
+Integration::BitmapPtr DownscaleBitmap( Integration::Bitmap& bitmap, ImageDimensions desired, FittingMode::Type fittingMode, SamplingMode::Type samplingMode );
 /**@}*/
 
 /**
@@ -187,8 +104,8 @@ void DownscaleInPlacePow2( unsigned char * const pixels,
                            unsigned int inputHeight,
                            unsigned int desiredWidth,
                            unsigned int desiredHeight,
-                           ImageAttributes::ScalingMode scalingMode,
-                           ImageAttributes::FilterMode filterMode,
+                           FittingMode::Type fittingMode,
+                           SamplingMode::Type samplingMode,
                            unsigned& outWidth,
                            unsigned& outHeight );
 
@@ -560,7 +477,7 @@ inline unsigned int BilinearFilter1Component(unsigned int tl, unsigned int tr, u
 {
   DALI_ASSERT_DEBUG( fractBlendHorizontal <= 65535u && "Factor should be in 0.16 fixed-point." );
   DALI_ASSERT_DEBUG( fractBlendVertical   <= 65535u && "Factor should be in 0.16 fixed-point." );
-  //
+
   const unsigned int topBlend = WeightedBlendIntToFixed1616( tl, tr, fractBlendHorizontal );
   const unsigned int botBlend = WeightedBlendIntToFixed1616( bl, br, fractBlendHorizontal );
   const uint64_t blended2x2 = WeightedBlendFixed1616ToFixed1632( topBlend, botBlend, fractBlendVertical );
diff --git a/platform-abstractions/tizen/image-loaders/image-loader-input.h b/platform-abstractions/tizen/image-loaders/image-loader-input.h
new file mode 100644 (file)
index 0000000..7aecffe
--- /dev/null
@@ -0,0 +1,65 @@
+#ifndef __DALI_TIZEN_PLATFORM_IMAGE_LOADER_INPUT_H__
+#define __DALI_TIZEN_PLATFORM_IMAGE_LOADER_INPUT_H__
+
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// EXTERNAL INCLUDES
+#include <cstdio>
+#include <dali/public-api/images/image-operations.h>
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+namespace TizenPlatform
+{
+namespace ImageLoader
+{
+
+
+/**
+ * @brief A simple immutable struct to bundle together parameters for scaling an image.
+ * @ToDo Move this to adaptor internal?
+ * @ToDo Rename it after the move to ImageScalingParameters.
+ */
+class ScalingParameters
+{
+public:
+  ScalingParameters( ImageDimensions dimensions = ImageDimensions(), FittingMode::Type fittingMode = FittingMode::DEFAULT, SamplingMode::Type samplingMode = SamplingMode::DEFAULT ) :
+    dimensions(dimensions), scalingMode(fittingMode), samplingMode(samplingMode) {}
+  const ImageDimensions dimensions;
+  const FittingMode::Type scalingMode;
+  const SamplingMode::Type samplingMode;
+};
+
+  /**
+   * @brief Bundle-up the data pushed into an image loader.
+   */
+struct Input
+{
+  Input( FILE* file, ScalingParameters scalingParameters = ScalingParameters(), bool reorientationRequested = true ) :
+    file(file), scalingParameters(scalingParameters), reorientationRequested(reorientationRequested) {}
+  FILE* file;
+  ScalingParameters scalingParameters;
+  bool reorientationRequested;
+};
+
+} // ImageLoader
+} // TizenPlatform
+} // Dali
+
+#endif // __DALI_TIZEN_PLATFORM_IMAGE_LOADER_INPUT_H__
index 86a548f..5d7c8b3 100644 (file)
@@ -17,7 +17,6 @@
 #include "image-loader.h"
 
 #include <dali/public-api/common/ref-counted-dali-vector.h>
-#include <dali/public-api/images/image-attributes.h>
 #include <dali/integration-api/bitmap.h>
 #include <dali/integration-api/debug.h>
 
@@ -29,6 +28,8 @@
 #include "loader-ktx.h"
 #include "loader-wbmp.h"
 #include "image-operations.h"
+#include "image-loader-input.h"
+#include "portable/file-closer.h"
 
 using namespace Dali::Integration;
 
@@ -39,11 +40,11 @@ namespace TizenPlatform
 
 namespace
 {
-typedef bool (*LoadBitmapFunction)( FILE*, Bitmap&, ImageAttributes&, const ResourceLoadingClient& );
-typedef bool (*LoadBitmapHeaderFunction)(FILE*, const ImageAttributes& attrs, unsigned int& width, unsigned int& height );
+typedef bool (*LoadBitmapFunction)( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap );
+typedef bool (*LoadBitmapHeaderFunction)( const ImageLoader::Input& input, unsigned int& width, unsigned int& height );
 
 #if defined(DEBUG_ENABLED)
-Integration::Log::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_IMAGE_LOADING");
+Integration::Log::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_IMAGE_LOADING" );
 #endif
 
 /**
@@ -170,7 +171,7 @@ bool GetBitmapLoaderFunctions( FILE *fp,
 
   bool loaderFound = false;
   const BitmapLoader *lookupPtr = BITMAP_LOADER_LOOKUP_TABLE;
-  ImageAttributes attrs;
+  ImageLoader::Input defaultInput( fp );
 
   // try hinted format first
   if ( format != FORMAT_UNKNOWN )
@@ -181,7 +182,7 @@ bool GetBitmapLoaderFunctions( FILE *fp,
     {
       unsigned int width = 0;
       unsigned int height = 0;
-      loaderFound = lookupPtr->header(fp, attrs, width, height );
+      loaderFound = lookupPtr->header( fp, width, height );
     }
   }
 
@@ -197,7 +198,7 @@ bool GetBitmapLoaderFunctions( FILE *fp,
         // to seperate ico file format and wbmp file format
         unsigned int width = 0;
         unsigned int height = 0;
-        loaderFound = lookupPtr->header(fp, attrs, width, height);
+        loaderFound = lookupPtr->header(fp, width, height);
       }
       if (loaderFound)
       {
@@ -216,7 +217,7 @@ bool GetBitmapLoaderFunctions( FILE *fp,
       // to seperate ico file format and wbmp file format
       unsigned int width = 0;
       unsigned int height = 0;
-      loaderFound = lookupPtr->header(fp, attrs, width, height);
+      loaderFound = lookupPtr->header(fp, width, height);
       if (loaderFound)
       {
         break;
@@ -247,9 +248,9 @@ bool GetBitmapLoaderFunctions( FILE *fp,
 namespace ImageLoader
 {
 
-bool ConvertStreamToBitmap(const ResourceType& resourceType, std::string path, FILE * const fp, const ResourceLoadingClient& client, BitmapPtr& ptr)
+bool ConvertStreamToBitmap( const ResourceType& resourceType, std::string path, FILE * const fp, const ResourceLoadingClient& client, BitmapPtr& ptr )
 {
-  DALI_LOG_TRACE_METHOD(gLogFilter);
+  DALI_LOG_TRACE_METHOD( gLogFilter );
   DALI_ASSERT_DEBUG( ResourceBitmap == resourceType.id );
 
   bool result = false;
@@ -267,20 +268,19 @@ bool ConvertStreamToBitmap(const ResourceType& resourceType, std::string path, F
                                    header,
                                    profile ) )
     {
-      bitmap = Bitmap::New(profile, ResourcePolicy::DISCARD );
+      bitmap = Bitmap::New( profile, ResourcePolicy::DISCARD );
 
-      DALI_LOG_SET_OBJECT_STRING(bitmap, path);
-      const BitmapResourceType& resType = static_cast<const BitmapResourceType&>(resourceType);
-      const ImageAttributes& requestedAttributes = resType.imageAttributes; //< Original attributes.
-      ImageAttributes attributes  = resType.imageAttributes; //< r/w copy of the attributes.
+      DALI_LOG_SET_OBJECT_STRING( bitmap, path );
+      const BitmapResourceType& resType = static_cast<const BitmapResourceType&>( resourceType );
+      const ScalingParameters scalingParameters( resType.size, resType.scalingMode, resType.samplingMode );
+      const ImageLoader::Input input( fp, scalingParameters, resType.orientationCorrection );
 
       // Check for cancellation now we have hit the filesystem, done some allocation, and burned some cycles:
       // This won't do anything from synchronous API, it's only useful when called from another thread.
       client.InterruptionPoint(); // Note: By design, this can throw an exception
 
       // Run the image type decoder:
-      // Note, this can overwrite the attributes parameter.
-      result = function( fp, *bitmap, attributes, client );
+      result = function( client, input, *bitmap );
 
       if (!result)
       {
@@ -288,13 +288,13 @@ bool ConvertStreamToBitmap(const ResourceType& resourceType, std::string path, F
         bitmap = 0;
       }
 
-      // Apply the requested image attributes in best-effort fashion:
+      // Apply the requested image attributes if not interrupted:
       client.InterruptionPoint(); // Note: By design, this can throw an exception
-      bitmap = Internal::Platform::ApplyAttributesToBitmap( bitmap, requestedAttributes );
+      bitmap = Internal::Platform::ApplyAttributesToBitmap( bitmap, resType.size, resType.scalingMode, resType.samplingMode );
     }
     else
     {
-      DALI_LOG_WARNING("Image Decoder for %s unavailable\n", path.c_str());
+      DALI_LOG_WARNING( "Image Decoder for %s unavailable\n", path.c_str() );
     }
   }
 
@@ -307,7 +307,8 @@ ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& reso
   ResourcePointer resource;
   BitmapPtr bitmap = 0;
 
-  FILE * const fp = fopen( resourcePath.c_str(), "rb" );
+  Internal::Platform::FileCloser fc( resourcePath.c_str(), "rb");
+  FILE * const fp = fc.GetFile();
   if( fp != NULL )
   {
     bool result = ConvertStreamToBitmap( resourceType, resourcePath, fp, StubbedResourceLoadingClient(), bitmap );
@@ -315,17 +316,22 @@ ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& reso
     {
       resource.Reset(bitmap.Get());
     }
-    fclose(fp);
   }
   return resource;
 }
 
-
-void GetClosestImageSize( const std::string& filename,
-                          const ImageAttributes& attributes,
-                          Vector2 &closestSize )
+///@ToDo: Rename GetClosestImageSize() functions. Make them use the orientation correction and scaling information. Requires jpeg loader to tell us about reorientation. [Is there still a requirement for this functionality at all?]
+ImageDimensions  GetClosestImageSize( const std::string& filename,
+                                      ImageDimensions size,
+                                      FittingMode::Type fittingMode,
+                                      SamplingMode::Type samplingMode,
+                                      bool orientationCorrection )
 {
-  FILE *fp = fopen(filename.c_str(), "rb");
+  unsigned int width = 0;
+  unsigned int height = 0;
+
+  Internal::Platform::FileCloser fc(filename.c_str(), "rb");
+  FILE *fp = fc.GetFile();
   if (fp != NULL)
   {
     LoadBitmapFunction loaderFunction;
@@ -338,32 +344,32 @@ void GetClosestImageSize( const std::string& filename,
                                    headerFunction,
                                    profile ) )
     {
-      unsigned int width;
-      unsigned int height;
+      const ImageLoader::Input input( fp, ScalingParameters( size, fittingMode, samplingMode ), orientationCorrection );
 
-      const bool read_res = headerFunction(fp, attributes, width, height);
+      const bool read_res = headerFunction( input, width, height );
       if(!read_res)
       {
         DALI_LOG_WARNING("Image Decoder failed to read header for %s\n", filename.c_str());
       }
-
-      closestSize.width = (float)width;
-      closestSize.height = (float)height;
     }
     else
     {
       DALI_LOG_WARNING("Image Decoder for %s unavailable\n", filename.c_str());
     }
-    fclose(fp);
   }
+  return ImageDimensions( width, height );
 }
 
 
-void GetClosestImageSize( ResourcePointer resourceBuffer,
-                          const ImageAttributes& attributes,
-                          Vector2 &closestSize )
+
+ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
+                                     ImageDimensions size,
+                                     FittingMode::Type fittingMode,
+                                     SamplingMode::Type samplingMode,
+                                     bool orientationCorrection )
 {
-  BitmapPtr bitmap = 0;
+  unsigned int width = 0;
+  unsigned int height = 0;
 
   // Get the blob of binary data that we need to decode:
   DALI_ASSERT_DEBUG( resourceBuffer );
@@ -379,7 +385,8 @@ void GetClosestImageSize( ResourcePointer resourceBuffer,
     if( blobBytes != 0 && blobSize > 0U )
     {
       // Open a file handle on the memory buffer:
-      FILE * const fp = fmemopen(blobBytes, blobSize, "rb");
+      Internal::Platform::FileCloser fc( blobBytes, blobSize, "rb" );
+      FILE *fp = fc.GetFile();
       if ( fp != NULL )
       {
         LoadBitmapFunction loaderFunction;
@@ -392,21 +399,17 @@ void GetClosestImageSize( ResourcePointer resourceBuffer,
                                        headerFunction,
                                        profile ) )
         {
-          unsigned int width;
-          unsigned int height;
-          const bool read_res = headerFunction(fp, attributes, width, height);
-          if(!read_res)
+          const ImageLoader::Input input( fp, ScalingParameters( size, fittingMode, samplingMode ), orientationCorrection );
+          const bool read_res = headerFunction( input, width, height );
+          if( !read_res )
           {
-            DALI_LOG_WARNING("Image Decoder failed to read header for resourceBuffer\n");
+            DALI_LOG_WARNING( "Image Decoder failed to read header for resourceBuffer\n" );
           }
-
-          closestSize.width = (float) width;
-          closestSize.height = (float) height;
         }
-        fclose(fp);
       }
     }
   }
+  return ImageDimensions( width, height );
 }
 
 } // ImageLoader
index ea7b3a5..15e3318 100644 (file)
  * limitations under the License.
  */
 
+// EXTERNAL INCLUDES
+#include <dali/public-api/images/image-operations.h>
 #include <dali/integration-api/resource-cache.h>
 #include <dali/integration-api/resource-types.h>
 #include <dali/integration-api/bitmap.h>
+
+// INTERNAL INCLUDES
 #include "resource-loading-client.h"
 
 namespace Dali
@@ -51,13 +55,17 @@ bool ConvertBitmapToStream( std::string path, FILE * const fp, Integration::Bitm
 
 Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath );
 
-void GetClosestImageSize( const std::string& filename,
-                          const ImageAttributes& attributes,
-                          Vector2 &closestSize );
+ImageDimensions  GetClosestImageSize( const std::string& filename,
+                          ImageDimensions size,
+                          FittingMode::Type fittingMode,
+                          SamplingMode::Type samplingMode,
+                          bool orientationCorrection );
 
-void GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
-                          const ImageAttributes& attributes,
-                          Vector2 &closestSize );
+ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
+                          ImageDimensions size,
+                          FittingMode::Type fittingMode,
+                          SamplingMode::Type samplingMode,
+                          bool orientationCorrection );
 
 } // ImageLoader
 } // TizenPlatform
index 3c10913..9371b11 100644 (file)
@@ -20,7 +20,6 @@
 #include <dali/public-api/common/vector-wrapper.h>
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/bitmap.h>
-#include <dali/public-api/images/image-attributes.h>
 
 #include <cstdlib>
 
@@ -1042,19 +1041,20 @@ bool DecodeRLE8(FILE *fp,
 
 } // unnamed namespace
 
-bool LoadBmpHeader(FILE *fp, const ImageAttributes& attributes, unsigned int &width, unsigned int &height)
+bool LoadBmpHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height )
 {
   BmpFileHeader fileHeader;
   BmpInfoHeader infoHeader;
 
-  bool ret = LoadBmpHeader(fp, width, height, fileHeader, infoHeader);
+  bool ret = LoadBmpHeader( input.file, width, height, fileHeader, infoHeader );
 
   return ret;
 }
 
-bool LoadBitmapFromBmp( FILE *fp, Bitmap& bitmap, ImageAttributes& attributes, const ResourceLoadingClient& client )
+bool LoadBitmapFromBmp( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
-  DALI_ASSERT_DEBUG(bitmap.GetPackedPixelsProfile() != 0 && "Need a packed pixel bitmap to load into.");
+  DALI_ASSERT_DEBUG( bitmap.GetPackedPixelsProfile() != 0 && "Need a packed pixel bitmap to load into." );
+  FILE* const fp = input.file;
   if(fp == NULL)
   {
     DALI_LOG_ERROR("Error loading bitmap\n");
@@ -1355,7 +1355,6 @@ bool LoadBitmapFromBmp( FILE *fp, Bitmap& bitmap, ImageAttributes& attributes, c
     return false;
   }
 
-  attributes.SetSize(infoHeader.width, infoHeader.height);
   return true;
 }
 
index 7c306c3..c5f9957 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <cstdio>
+#include "image-loader-input.h"
 
 namespace Dali
 {
@@ -49,7 +50,7 @@ const unsigned char MAGIC_BYTE_2 = 0x4D;
  * @param[in]  attributes  Describes the dimensions, pixel format and other details for loading the image data
  * @return  true if file decoded successfully, false otherwise
  */
-bool LoadBitmapFromBmp( FILE *fp, Integration::Bitmap& bitmap, ImageAttributes& attributes, const ResourceLoadingClient& client );
+bool LoadBitmapFromBmp( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * Loads the header of a BMP file and fills in the width and height appropriately.
@@ -59,7 +60,7 @@ bool LoadBitmapFromBmp( FILE *fp, Integration::Bitmap& bitmap, ImageAttributes&
  * @param[out]  height  Is set with the height of the image
  * @return true if the file's header was read successully, false otherwise
  */
-bool LoadBmpHeader(FILE *fp, const ImageAttributes& attributes, unsigned int &width, unsigned int &height);
+bool LoadBmpHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height );
 
 } // namespace TizenPlatform
 
index 6d9ed0e..cac1bff 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/bitmap.h>
-#include <dali/public-api/images/image-attributes.h>
 
 namespace Dali
 {
@@ -174,7 +173,7 @@ GifColorType* GetImageColors( SavedImage* image, GifFileType* gifInfo )
 }
 
 /// Called when we want to handle IMAGE_DESC_RECORD_TYPE
-bool HandleImageDescriptionRecordType( Bitmap& bitmap, ImageAttributes& attributes, GifFileType* gifInfo, unsigned int width, unsigned int height, bool& finished )
+bool HandleImageDescriptionRecordType( Bitmap& bitmap, GifFileType* gifInfo, unsigned int width, unsigned int height, bool& finished )
 {
   if ( DGifGetImageDesc( gifInfo ) == GIF_ERROR )
   {
@@ -206,8 +205,6 @@ bool HandleImageDescriptionRecordType( Bitmap& bitmap, ImageAttributes& attribut
     return false;
   }
 
-  // TODO: Add scaling support
-
   // Get the colormap for the GIF
   GifColorType* color( GetImageColors( image, gifInfo ) );
 
@@ -231,8 +228,6 @@ bool HandleImageDescriptionRecordType( Bitmap& bitmap, ImageAttributes& attribut
     }
   }
 
-  attributes.SetSize( actualWidth, actualHeight );
-
   finished = true;
 
   return true;
@@ -263,16 +258,18 @@ bool HandleExtensionRecordType( GifFileType* gifInfo )
 
 } // unnamed namespace
 
-bool LoadGifHeader(FILE *fp, const ImageAttributes& attributes, unsigned int &width, unsigned int &height )
+bool LoadGifHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height )
 {
   GifFileType* gifInfo = NULL;
   AutoCleanupGif autoCleanupGif(gifInfo);
+  FILE* const fp = input.file;
 
   return LoadGifHeader(fp, width, height, &gifInfo);
 }
 
-bool LoadBitmapFromGif(FILE *fp, Bitmap& bitmap, ImageAttributes& attributes, const ResourceLoadingClient& client )
+bool LoadBitmapFromGif( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
+  FILE* const fp = input.file;
   // Load the GIF Header file.
 
   GifFileType* gifInfo( NULL );
@@ -300,7 +297,7 @@ bool LoadBitmapFromGif(FILE *fp, Bitmap& bitmap, ImageAttributes& attributes, co
 
     if( IMAGE_DESC_RECORD_TYPE == recordType )
     {
-      if ( !HandleImageDescriptionRecordType( bitmap, attributes, gifInfo, width, height, finished ) )
+      if ( !HandleImageDescriptionRecordType( bitmap, gifInfo, width, height, finished ) )
       {
         return false;
       }
index b3a3699..9b9c330 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <cstdio>
+#include "image-loader-input.h"
 
 namespace Dali
 {
@@ -50,7 +51,7 @@ const unsigned char MAGIC_BYTE_2 = 0x49;
  * @param[in]  attributes  Describes the dimensions, pixel format and other details for loading the image data
  * @return  true if file decoded successfully, false otherwise
  */
-bool LoadBitmapFromGif( FILE *fp, Integration::Bitmap& bitmap, ImageAttributes& attributes, const ResourceLoadingClient& client );
+bool LoadBitmapFromGif( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * Loads the header of a GIF file and fills in the width and height appropriately.
@@ -60,7 +61,7 @@ bool LoadBitmapFromGif( FILE *fp, Integration::Bitmap& bitmap, ImageAttributes&
  * @param[in/out]  height  Is set with the height of the image
  * @return true if the file's header was read successully, false otherwise
  */
-bool LoadGifHeader(FILE *fp, const ImageAttributes& attributes, unsigned int &width, unsigned int &height );
+bool LoadGifHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height );
 
 } // namespace TizenPlatform
 
index be812cf..8bea0d1 100644 (file)
@@ -57,7 +57,6 @@
 // INTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/bitmap.h>
-#include <dali/public-api/images/image-attributes.h>
 
 namespace Dali
 {
@@ -339,11 +338,12 @@ bool LoadIcoHeaderHelper( FILE* fp,
 
 }//unnamed namespace
 
-bool LoadIcoHeader(FILE *fp, const ImageAttributes& attributes, unsigned int &width, unsigned int &height )
+bool LoadIcoHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height )
 {
   IcoData chosen;
   Dali::Vector<unsigned char> map;
   unsigned int fsize;
+  FILE* const fp = input.file;
 
   if ( false == LoadIcoHeaderHelper(fp, chosen, map, fsize) )
   {
@@ -356,11 +356,12 @@ bool LoadIcoHeader(FILE *fp, const ImageAttributes& attributes, unsigned int &wi
   return true;
 }
 
-bool LoadBitmapFromIco( FILE *fp, Integration::Bitmap& bitmap, ImageAttributes& attributes, const ResourceLoadingClient& client )
+bool LoadBitmapFromIco( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   IcoData chosen;
   Dali::Vector<unsigned char> map;
   unsigned int fsize;
+  FILE* const fp = input.file;
 
   if ( false == LoadIcoHeaderHelper(fp, chosen, map, fsize) )
   {
@@ -733,8 +734,6 @@ bool LoadBitmapFromIco( FILE *fp, Integration::Bitmap& bitmap, ImageAttributes&
   memset(pixels, 0, w * h * 4);
   memcpy(pixels, (unsigned char*)&surface[0], w * h * 4);
 
-  attributes.SetSize(w, h);
-
   return true;
 }
 
index d481baf..d844e77 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <cstdio>
+#include "image-loader-input.h"
 
 namespace Dali
 {
@@ -41,9 +42,9 @@ const unsigned char MAGIC_BYTE_1 = 0x00;
 const unsigned char MAGIC_BYTE_2 = 0x00;
 }
 
-bool LoadBitmapFromIco( FILE *fp, Integration::Bitmap& bitmap, ImageAttributes& attributes, const ResourceLoadingClient& client );
+bool LoadBitmapFromIco( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
-bool LoadIcoHeader(FILE *fp, const ImageAttributes& attributes, unsigned int &width, unsigned int &height );
+bool LoadIcoHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height );
 
 }
 
index 28e064e..a18e45a 100755 (executable)
@@ -19,7 +19,6 @@
 #include "loader-jpeg.h"
 #include "resource-loading-client.h"
 #include <dali/integration-api/bitmap.h>
-#include <dali/public-api/images/image-attributes.h>
 #include <resource-loader/debug/resource-loader-debug.h>
 #include "platform-capabilities.h"
 
@@ -66,25 +65,6 @@ namespace
      char B;
   };
 
-  struct RGBA8888Type
-  {
-     char R;
-     char G;
-     char B;
-     char A;
-  };
-
-  struct RGB565Type
-  {
-    char RG;
-    char GB;
-  };
-
-  struct L8Type
-  {
-    char gray;
-  };
-
   /**
    * @brief Error handling bookeeping for the JPEG Turbo library's
    * setjmp/longjmp simulated exceptions.
@@ -229,9 +209,10 @@ bool LoadJpegHeader( FILE *fp, unsigned int &width, unsigned int &height )
   return true;
 }
 
-bool LoadBitmapFromJpeg( FILE *fp, Bitmap& bitmap, ImageAttributes& attributes, const ResourceLoadingClient& client )
+bool LoadBitmapFromJpeg( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   const int flags= 0;
+  FILE* const fp = input.file;
 
   if( fseek(fp,0,SEEK_END) )
   {
@@ -294,7 +275,7 @@ bool LoadBitmapFromJpeg( FILE *fp, Bitmap& bitmap, ImageAttributes& attributes,
 
   JPGFORM_CODE transform = JPGFORM_NONE;
 
-  if( attributes.GetOrientationCorrection() )
+  if( input.reorientationRequested )
   {
     ExifAutoPtr exifData( exif_data_new_from_data(jpegBufferPtr, jpegBufferSize) );
     if( exifData.mData )
@@ -318,8 +299,8 @@ bool LoadBitmapFromJpeg( FILE *fp, Bitmap& bitmap, ImageAttributes& attributes,
     return false;
   }
 
-  int requiredWidth  = attributes.GetWidth();
-  int requiredHeight = attributes.GetHeight();
+  int requiredWidth  = input.scalingParameters.dimensions.GetWidth();
+  int requiredHeight = input.scalingParameters.dimensions.GetHeight();
 
   // If transform is a 90 or 270 degree rotation, the logical width and height
   // request from the client needs to be adjusted to account by effectively
@@ -351,8 +332,6 @@ bool LoadBitmapFromJpeg( FILE *fp, Bitmap& bitmap, ImageAttributes& attributes,
     return false;
   }
 
-  attributes.SetSize( scaledPostXformWidth, scaledPostXformHeight );
-
   const unsigned int  bufferWidth  = GetTextureDimension( scaledPreXformWidth );
   const unsigned int  bufferHeight = GetTextureDimension( scaledPreXformHeight );
 
@@ -397,6 +376,7 @@ bool LoadBitmapFromJpeg( FILE *fp, Bitmap& bitmap, ImageAttributes& attributes,
   return result;
 }
 
+///@Todo: Move all these rotation functions to portable/image-operations and take "Jpeg" out of their names.
 bool JpegRotate90(unsigned char *buffer, int width, int height, int bpp)
 {
   int  w, iw, ih, hw = 0;
@@ -772,10 +752,11 @@ ExifData* LoadExifData( FILE* fp )
   return exifData;
 }
 
-bool LoadJpegHeader(FILE *fp, const ImageAttributes& attributes, unsigned int &width, unsigned int &height)
+bool LoadJpegHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height )
 {
-  unsigned int requiredWidth  = attributes.GetWidth();
-  unsigned int requiredHeight = attributes.GetHeight();
+  unsigned int requiredWidth  = input.scalingParameters.dimensions.GetWidth();
+  unsigned int requiredHeight = input.scalingParameters.dimensions.GetHeight();
+  FILE* const fp = input.file;
 
   bool success = false;
   if( requiredWidth == 0 && requiredHeight == 0 )
@@ -791,7 +772,7 @@ bool LoadJpegHeader(FILE *fp, const ImageAttributes& attributes, unsigned int &w
     {
       JPGFORM_CODE transform = JPGFORM_NONE;
 
-      if( attributes.GetOrientationCorrection() )
+      if( input.reorientationRequested )
       {
         ExifAutoPtr exifData( LoadExifData( fp ) );
         if( exifData.mData )
index db7e145..357f213 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/bitmap.h>
-#include <dali/public-api/images/image-attributes.h>
 #include <dali/public-api/math/math-utils.h>
 #include <dali/public-api/math/vector2.h>
 
index bcaa3cf..4c6d783 100644 (file)
@@ -22,6 +22,7 @@
 #include <dali/public-api/common/vector-wrapper.h>
 #include <dali/public-api/images/pixel.h>
 #include "image-encoder.h"
+#include "image-loader-input.h"
 
 namespace Dali
 {
@@ -52,7 +53,7 @@ const unsigned char MAGIC_BYTE_2 = 0xD8;
  * @param[in]  attributes  Describes the dimensions, pixel format and other details for loading the image data
  * @return  true if file decoded successfully, false otherwise
  */
-bool LoadBitmapFromJpeg( FILE *fp, Integration::Bitmap& bitmap, ImageAttributes& attributes, const ResourceLoadingClient& client );
+bool LoadBitmapFromJpeg( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * Loads the header of a JPEG file and fills in the width and height appropriately.
@@ -65,7 +66,7 @@ bool LoadBitmapFromJpeg( FILE *fp, Integration::Bitmap& bitmap, ImageAttributes&
  * @param[in/out]  height  Is set with the height of the image
  * @return true if the file's header was read successully, false otherwise
  */
-bool LoadJpegHeader(FILE *fp, const ImageAttributes& attributes, unsigned int &width, unsigned int &height);
+bool LoadJpegHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height );
 
 /**
  * Encode raw pixel data to JPEG format.
index 6d12936..ca58304 100755 (executable)
@@ -25,7 +25,6 @@
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/bitmap.h>
 #include <dali/public-api/images/pixel.h>
-#include <dali/public-api/images/image-attributes.h>
 
 namespace Dali
 {
@@ -295,18 +294,22 @@ bool LoadKtxHeader(FILE * const fp, unsigned int &width, unsigned int &height, K
 } // unnamed namespace
 
 // File loading API entry-point:
-bool LoadKtxHeader(FILE * const fp, const ImageAttributes& attributes, unsigned int &width, unsigned int &height)
+bool LoadKtxHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height )
 {
   KtxFileHeader fileHeader;
+  FILE* const fp = input.file;
+
   bool ret = LoadKtxHeader(fp, width, height, fileHeader);
   return ret;
 }
 
 // File loading API entry-point:
-bool LoadBitmapFromKtx( FILE * const fp, Bitmap& bitmap, ImageAttributes& attributes, const ResourceLoadingClient& client )
+bool LoadBitmapFromKtx( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   DALI_COMPILE_TIME_ASSERT( sizeof(Byte) == 1);
   DALI_COMPILE_TIME_ASSERT( sizeof(uint32_t) == 4);
+
+  FILE* const fp = input.file;
   if( fp == NULL )
   {
     DALI_LOG_ERROR( "Null file handle passed to KTX compressed bitmap file loader.\n" );
@@ -368,9 +371,6 @@ bool LoadBitmapFromKtx( FILE * const fp, Bitmap& bitmap, ImageAttributes& attrib
     return false;
   }
 
-  // Ignore all input requests from image attributes and set the available metadata:
-  attributes.SetSize(width, height);
-
   return true;
 }
 
index 5a5e0ae..e69d13c 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <cstdio>
+#include "image-loader-input.h"
 
 namespace Dali
 {
@@ -50,7 +51,7 @@ const unsigned char MAGIC_BYTE_2 = 0x4B;
  * @param[in]  attributes  Describes the dimensions, pixel format and other details for loading the image data
  * @return  true if file loaded successfully, false otherwise
  */
-bool LoadBitmapFromKtx( FILE * const fp, Integration::Bitmap& bitmap, ImageAttributes& attributes, const ResourceLoadingClient& client );
+bool LoadBitmapFromKtx( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * Loads the header of a KTX file and fills in the width and height appropriately.
@@ -60,7 +61,7 @@ bool LoadBitmapFromKtx( FILE * const fp, Integration::Bitmap& bitmap, ImageAttri
  * @param[out]  height  Is set with the height of the image
  * @return true if the file's header was read successully, false otherwise
  */
-bool LoadKtxHeader(FILE * const fp, const ImageAttributes& attributes, unsigned int &width, unsigned int &height);
+bool LoadKtxHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height );
 
 } // namespace TizenPlatform
 
index 209834c..d6d6273 100644 (file)
@@ -26,7 +26,6 @@
 #include <dali/integration-api/bitmap.h>
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/images/image.h>
-#include <dali/public-api/images/image-attributes.h>
 #include "dali/public-api/math/math-utils.h"
 #include "dali/public-api/math/vector2.h"
 #include "platform-capabilities.h"
@@ -118,18 +117,18 @@ bool LoadPngHeader(FILE *fp, unsigned int &width, unsigned int &height, png_stru
 
 } // namespace - anonymous
 
-bool LoadPngHeader(FILE *fp, const ImageAttributes& attributes, unsigned int &width, unsigned int &height )
+bool LoadPngHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height )
 {
   png_structp png = NULL;
   png_infop info = NULL;
   auto_png autoPng(png, info);
 
-  bool success = LoadPngHeader(fp, width, height, png, info);
+  bool success = LoadPngHeader( input.file, width, height, png, info );
 
   return success;
 }
 
-bool LoadBitmapFromPng( FILE *fp, Bitmap& bitmap, ImageAttributes& attributes, const ResourceLoadingClient& client )
+bool LoadBitmapFromPng( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   png_structp png = NULL;
   png_infop info = NULL;
@@ -144,7 +143,7 @@ bool LoadBitmapFromPng( FILE *fp, Bitmap& bitmap, ImageAttributes& attributes, c
   bool valid = false;
 
   // Load info from the header
-  if( !LoadPngHeader(fp, width, height, png, info) )
+  if( !LoadPngHeader( input.file, width, height, png, info ) )
   {
     return false;
   }
@@ -309,9 +308,6 @@ bool LoadBitmapFromPng( FILE *fp, Bitmap& bitmap, ImageAttributes& attributes, c
   // decode image
   png_read_image(png, rows);
 
-  // set the attributes
-  attributes.SetSize( width, height );
-
   free(rows);
 
   return true;
index f1dedb3..77b9422 100644 (file)
@@ -22,6 +22,7 @@
 #include <dali/public-api/common/vector-wrapper.h>
 #include <dali/public-api/images/pixel.h>
 #include "image-encoder.h"
+#include "image-loader-input.h"
 
 namespace Dali
 {
@@ -51,7 +52,7 @@ const unsigned char MAGIC_BYTE_2 = 0x50;
  * @param[in]  attributes  Describes the dimensions, pixel format and other details for loading the image data
  * @return  true if file decoded successfully, false otherwise
  */
-bool LoadBitmapFromPng( FILE *fp, Integration::Bitmap& bitmap, ImageAttributes& attributes, const ResourceLoadingClient& client );
+bool LoadBitmapFromPng( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * Loads the header of a PNG file and fills in the width and height appropriately.
@@ -61,7 +62,7 @@ bool LoadBitmapFromPng( FILE *fp, Integration::Bitmap& bitmap, ImageAttributes&
  * @param[out]  height  Is set with the height of the image
  * @return true if the file's header was read successully, false otherwise
  */
-bool LoadPngHeader(FILE *fp, const ImageAttributes& attributes, unsigned int &width, unsigned int &height );
+bool LoadPngHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height );
 
 /**
  * A bucket of bytes representing a PNG image.
index 5ca55b7..8014bc6 100755 (executable)
@@ -26,7 +26,6 @@
 // INTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/bitmap.h>
-#include <dali/public-api/images/image-attributes.h>
 #include <dali/public-api/common/dali-vector.h>
 
 namespace Dali
@@ -93,9 +92,9 @@ int extractMultiByteInteger(unsigned int *data, void *map, size_t length, size_t
 
 }// end unnamed namespace
 
-bool LoadBitmapFromWbmp( FILE *fp, Integration::Bitmap& bitmap, ImageAttributes& attributes, const ResourceLoadingClient& client )
+bool LoadBitmapFromWbmp( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
-
+  FILE* const fp = input.file;
   if(fp == NULL)
   {
     DALI_LOG_ERROR("Error loading bitmap\n");
@@ -210,14 +209,14 @@ bool LoadBitmapFromWbmp( FILE *fp, Integration::Bitmap& bitmap, ImageAttributes&
   pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer(Pixel::L8, w, h);//Pixel::RGBA8888
 
   memcpy(pixels, (unsigned char*)&surface[0], w * h );//w * h * 4
-  attributes.SetSize(w, h);
 
   return true;
 }
 
 
-bool LoadWbmpHeader(FILE *fp, const ImageAttributes& attributes, unsigned int &width, unsigned int &height )
+bool LoadWbmpHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height )
 {
+  FILE* const fp = input.file;
   if(fp == NULL)
   {
     DALI_LOG_ERROR("Error loading bitmap\n");
index 21d8081..6298cfc 100755 (executable)
@@ -19,6 +19,7 @@
  */
 
 #include <cstdio>
+#include "image-loader-input.h"
 
 namespace Dali
 {
@@ -34,9 +35,9 @@ namespace TizenPlatform
 
 class ResourceLoadingClient;
 
-bool LoadBitmapFromWbmp( FILE *fp, Integration::Bitmap& bitmap, ImageAttributes& attributes, const ResourceLoadingClient& client );
+bool LoadBitmapFromWbmp( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
-bool LoadWbmpHeader(FILE *fp, const ImageAttributes& attributes, unsigned int &width, unsigned int &height );
+bool LoadWbmpHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height );
 
 }
 
index e7d2bb0..f99c7c5 100644 (file)
@@ -103,23 +103,24 @@ int TizenPlatformAbstraction::GetDefaultFontSize() const
   return fontSize;
 }
 
-void TizenPlatformAbstraction::GetClosestImageSize( const std::string& filename,
-                                                  const ImageAttributes& attributes,
-                                                  Vector2& closestSize )
+ImageDimensions TizenPlatformAbstraction::GetClosestImageSize( const std::string& filename,
+                                                               ImageDimensions size,
+                                                               FittingMode::Type fittingMode,
+                                                               SamplingMode::Type samplingMode,
+                                                               bool orientationCorrection )
 {
-  closestSize = Vector2::ZERO;
-  ImageLoader::GetClosestImageSize(filename, attributes, closestSize );
+  return ImageLoader::GetClosestImageSize( filename, size, fittingMode, samplingMode, orientationCorrection );
 }
 
-void TizenPlatformAbstraction::GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
-                                                  const ImageAttributes& attributes,
-                                                  Vector2& closestSize )
+ImageDimensions TizenPlatformAbstraction::GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
+                                                               ImageDimensions size,
+                                                               FittingMode::Type fittingMode,
+                                                               SamplingMode::Type samplingMode,
+                                                               bool orientationCorrection )
 {
-  closestSize = Vector2::ZERO;
-  ImageLoader::GetClosestImageSize(resourceBuffer, attributes, closestSize );
+  return ImageLoader::GetClosestImageSize( resourceBuffer, size, fittingMode, samplingMode, orientationCorrection );
 }
 
-
 void TizenPlatformAbstraction::LoadResource(const Integration::ResourceRequest& request)
 {
   if (mResourceLoader)
index b9bf294..621b320 100644 (file)
@@ -76,16 +76,20 @@ public: // PlatformAbstraction overrides
   /**
    * @copydoc PlatformAbstraction::GetClosestImageSize()
    */
-  virtual void GetClosestImageSize( const std::string& filename,
-                                    const ImageAttributes& attributes,
-                                    Vector2& closestSize );
+  virtual ImageDimensions GetClosestImageSize( const std::string& filename,
+                                               ImageDimensions size,
+                                               FittingMode::Type fittingMode,
+                                               SamplingMode::Type samplingMode,
+                                               bool orientationCorrection );
 
   /**
    * @copydoc PlatformAbstraction::GetClosestImageSize()
    */
-  virtual void GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
-                                    const ImageAttributes& attributes,
-                                    Vector2& closestSize );
+  virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
+                                               ImageDimensions size,
+                                               FittingMode::Type fittingMode,
+                                               SamplingMode::Type samplingMode,
+                                               bool orientationCorrection );
 
   /**
    * @copydoc PlatformAbstraction::LoadResource()