Revert "Revert "Revert "[4.0] Exposing Exif Image metadata""" 05/165805/1
authordongsug.song <dongsug.song@samsung.com>
Thu, 4 Jan 2018 06:08:15 +0000 (15:08 +0900)
committerdongsug.song <dongsug.song@samsung.com>
Thu, 4 Jan 2018 06:11:33 +0000 (15:11 +0900)
This reverts commit f4b05fe51ddba1d7d2035103ef3cfcd1d4741d3c.

- MyContents crash error is solved BUT C#FS transparent image shows still X-box.

Change-Id: I85c83af68e32783fe0b668ed84616d7b376325ac

30 files changed:
adaptors/common/pixel-buffer-impl.cpp
adaptors/common/pixel-buffer-impl.h [changed mode: 0755->0644]
adaptors/devel-api/adaptor-framework/image-loading.cpp
adaptors/devel-api/adaptor-framework/pixel-buffer.cpp [changed mode: 0755->0644]
adaptors/devel-api/adaptor-framework/pixel-buffer.h [changed mode: 0755->0644]
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-platform-abstraction/utc-image-fitting-modes.cpp
platform-abstractions/portable/image-operations.cpp
platform-abstractions/portable/image-operations.h
platform-abstractions/tizen/image-loaders/image-loader.cpp
platform-abstractions/tizen/image-loaders/image-loader.h
platform-abstractions/tizen/image-loaders/loader-astc.cpp
platform-abstractions/tizen/image-loaders/loader-astc.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.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

index 23af6bc..7f12bac 100644 (file)
@@ -43,8 +43,7 @@ PixelBuffer::PixelBuffer( unsigned char* buffer,
                           unsigned int width,
                           unsigned int height,
                           Dali::Pixel::Format pixelFormat )
-: mMetadata(),
-  mBuffer( buffer ),
+: mBuffer( buffer ),
   mBufferSize( bufferSize ),
   mWidth( width ),
   mHeight( height ),
@@ -266,26 +265,6 @@ PixelBufferPtr PixelBuffer::NewCrop( const PixelBuffer& inBuffer, uint16_t x, ui
 
 }
 
-void PixelBuffer::SetMetadata( const Property::Map& map )
-{
-  mMetadata.reset(new Property::Map(map));
-}
-
-bool PixelBuffer::GetMetadata(Property::Map& outMetadata) const
-{
-  if( !mMetadata )
-  {
-    return false;
-  }
-  outMetadata = *mMetadata;
-  return true;
-}
-
-void PixelBuffer::SetMetadata(std::unique_ptr<Property::Map> metadata)
-{
-  mMetadata = std::move(metadata);
-}
-
 void PixelBuffer::Resize( ImageDimensions outDimensions )
 {
   if( mWidth != outDimensions.GetWidth() || mHeight != outDimensions.GetHeight() )
old mode 100755 (executable)
new mode 100644 (file)
index ae899be..2b57823
 #include <dali/public-api/images/image-operations.h> // For ImageDimensions
 #include <dali/public-api/images/pixel-data.h>
 #include <dali/public-api/object/base-object.h>
-#include <dali/public-api/object/property-map.h>
-
-// EXTERNAL INCLUDES
-#include <memory>
 
 namespace Dali
 {
@@ -185,27 +181,6 @@ public:
    */
   void MultiplyColorByAlpha();
 
-  /**
-   * @brief Sets image metadata
-   *
-   * @param map Property map containing Exif fields
-   */
-  void SetMetadata( const Property::Map& map );
-
-  /**
-   * @brief Returns image metadata as a property map
-   * @param[out] outMetadata Property map to copy the data into
-   * @return True on success
-   */
-  bool GetMetadata(Property::Map& outMetadata) const;
-
-  /**
-   * @brief Sets metadata property map for the pixel buffer
-   * @note The function takes over the ownership of the property map
-   * @param[in] metadata Property map to copy the data into
-   */
-  void SetMetadata(std::unique_ptr<Property::Map> metadata);
-
 private:
   /*
    * Undefined copy constructor.
@@ -262,12 +237,11 @@ private:
 
 private:
 
-  std::unique_ptr<Property::Map>  mMetadata;         ///< Metadata fields
-  unsigned char*                  mBuffer;           ///< The raw pixel data
-  unsigned int                    mBufferSize;       ///< Buffer sized in bytes
-  unsigned int                    mWidth;            ///< Buffer width in pixels
-  unsigned int                    mHeight;           ///< Buffer height in pixels
-  Pixel::Format                   mPixelFormat;      ///< Pixel format
+  unsigned char* mBuffer;           ///< The raw pixel data
+  unsigned int   mBufferSize;       ///< Buffer sized in bytes
+  unsigned int   mWidth;            ///< Buffer width in pixels
+  unsigned int   mHeight;           ///< Buffer height in pixels
+  Pixel::Format  mPixelFormat;      ///< Pixel format
 };
 
 } // namespace Adaptor
index 88203fe..2beb24d 100644 (file)
 #include "image-loading.h"
 
 // INTERNAL INCLUDES
-#include <dali/public-api/object/property-map.h>
 #include "image-loaders/image-loader.h"
 #include <resource-loader/network/file-download.h>
 #include <platform-abstractions/portable/file-reader.h>
 #include "pixel-buffer-impl.h"
 
-
-
 namespace Dali
 {
 
@@ -47,11 +44,23 @@ Devel::PixelBuffer LoadImageFromFile( const std::string& url, ImageDimensions si
   FILE * const fp = fileReader.GetFile();
   if( fp != NULL )
   {
-    Dali::Devel::PixelBuffer bitmap;
+    Integration::BitmapPtr bitmap;
     bool success = TizenPlatform::ImageLoader::ConvertStreamToBitmap( resourceType, url, fp, bitmap );
     if( success && bitmap )
     {
-      return bitmap;
+      // Use bitmap->GetBufferOwnership() to transfer the buffer ownership
+      // to pixelData.  The destroy of bitmap will not release the buffer,
+      // instead, the pixelBuffer is responsible for releasing when its
+      // reference count falls to zero.
+      Internal::Adaptor::PixelBufferPtr pixelBufferImpl =
+        Internal::Adaptor::PixelBuffer::New( bitmap->GetBufferOwnership(),
+                                             bitmap->GetBufferSize(),
+                                             bitmap->GetImageWidth(),
+                                             bitmap->GetImageHeight(),
+                                             bitmap->GetPixelFormat() );
+
+      Dali::Devel::PixelBuffer pixelBuffer( pixelBufferImpl.Get() );
+      return pixelBuffer;
     }
   }
   return Dali::Devel::PixelBuffer();
@@ -95,7 +104,7 @@ Devel::PixelBuffer DownloadImageSynchronously( const std::string& url, ImageDime
       FILE * const fp = fileReader.GetFile();
       if ( NULL != fp )
       {
-        Dali::Devel::PixelBuffer bitmap;
+        Integration::BitmapPtr bitmap;
         bool result = TizenPlatform::ImageLoader::ConvertStreamToBitmap(
           resourceType,
           url,
@@ -104,7 +113,15 @@ Devel::PixelBuffer DownloadImageSynchronously( const std::string& url, ImageDime
 
         if ( result && bitmap )
         {
-          return bitmap;
+          Internal::Adaptor::PixelBufferPtr pixelBufferImpl =
+            Internal::Adaptor::PixelBuffer::New( bitmap->GetBufferOwnership(),
+                                                 bitmap->GetBufferSize(),
+                                                 bitmap->GetImageWidth(),
+                                                 bitmap->GetImageHeight(),
+                                                 bitmap->GetPixelFormat() );
+
+          Dali::Devel::PixelBuffer pixelBuffer( pixelBufferImpl.Get() );
+          return pixelBuffer;
         }
         else
         {
old mode 100755 (executable)
new mode 100644 (file)
index 5fe2a28..35178e1
@@ -121,11 +121,6 @@ void PixelBuffer::MultiplyColorByAlpha()
   GetImplementation(*this).MultiplyColorByAlpha();
 }
 
-bool PixelBuffer::GetMetadata( Property::Map& metadata ) const
-{
-  return GetImplementation(*this).GetMetadata(metadata);
-}
-
 } // namespace Devel
 
 } // namespace Dali
old mode 100755 (executable)
new mode 100644 (file)
index 2290d54..82f8907
@@ -18,7 +18,6 @@
  *
  */
 
-// INTERNAL INCLUDES
 #include <dali/public-api/images/pixel.h>
 #include <dali/public-api/images/pixel-data.h>
 #include <dali/public-api/object/base-handle.h>
@@ -207,14 +206,6 @@ public:
    */
   void MultiplyColorByAlpha();
 
-  /**
-   * Returns Exif metadata as a property map
-   *
-   * @param[out] metadata Property map object to write into
-   * @return True on success
-   */
-  bool GetMetadata( Property::Map& metadata ) const;
-
 public:
 
   /**
index c8ced4a..c3f7abe 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "image-loaders.h"
 #include <dali-test-suite-utils.h>
-#include <adaptors/common/pixel-buffer-impl.h>
+
 
 AutoCloseFile::AutoCloseFile( FILE *fp )
 : filePtr( fp )
@@ -107,15 +107,17 @@ void TestImageLoading( const ImageDetails& image, const LoadFunctions& functions
   // Loading the header moves the pointer within the file so reset to start of file.
   fseek( fp, 0, 0 );
 
-  Dali::Devel::PixelBuffer bitmap;
+  // Create a bitmap object and store a pointer to that object so it is destroyed at the end.
+  Dali::Integration::Bitmap * bitmap = Dali::Integration::Bitmap::New( bitmapProfile, ResourcePolicy::OWNED_RETAIN  );
+  Dali::Integration::BitmapPtr bitmapPtr( bitmap );
 
   // Load Bitmap and check its return values.
-  DALI_TEST_CHECK( functions.loader( input, bitmap ) );
-  DALI_TEST_EQUALS( image.width,  bitmap.GetWidth(),  TEST_LOCATION );
-  DALI_TEST_EQUALS( image.height, bitmap.GetHeight(), TEST_LOCATION );
+  DALI_TEST_CHECK( functions.loader( 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( bitmap.GetBuffer() );
+  Dali::PixelBuffer* bufferPtr( bitmapPtr->GetBuffer() );
   Dali::PixelBuffer* refBufferPtr( image.refBuffer );
   for ( unsigned int i = 0; i < image.refBufferSize; ++i, ++bufferPtr, ++refBufferPtr )
   {
@@ -145,19 +147,21 @@ void CompareLoadedImageData( const ImageDetails& image, const LoadFunctions& fun
   // Loading the header moves the pointer within the file so reset to start of file.
   fseek( filePointer, 0, SEEK_SET );
 
-  Dali::Devel::PixelBuffer bitmap;
+  // Create a bitmap object and store a pointer to that object so it is destroyed at the end.
+  Dali::Integration::Bitmap * bitmap = Dali::Integration::Bitmap::New( Dali::Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN  );
+  Dali::Integration::BitmapPtr bitmapPointer( bitmap );
 
   // Load Bitmap and check its return values.
-  DALI_TEST_CHECK( functions.loader( input, bitmap ) );
-  DALI_TEST_EQUALS( image.width,  bitmap.GetWidth(),  TEST_LOCATION );
-  DALI_TEST_EQUALS( image.height, bitmap.GetHeight(), TEST_LOCATION );
+  DALI_TEST_CHECK( functions.loader( input, *bitmap ) );
+  DALI_TEST_EQUALS( image.width,  bitmap->GetImageWidth(),  TEST_LOCATION );
+  DALI_TEST_EQUALS( image.height, bitmap->GetImageHeight(), TEST_LOCATION );
 
   // Check the bytes per pixel.
-  const Pixel::Format pixelFormat = bitmap.GetPixelFormat();
+  const Pixel::Format pixelFormat = bitmap->GetPixelFormat();
   const unsigned int bytesPerPixel = Pixel::GetBytesPerPixel( pixelFormat );
 
   // Compare buffer generated with reference buffer.
-  Dali::PixelBuffer* pBitmapData( bitmap.GetBuffer() );
+  Dali::PixelBuffer* pBitmapData( bitmapPointer->GetBuffer() );
   const uint32_t* pMaster( master );
 
   // Loop through each pixel in the bitmap.
@@ -180,15 +184,15 @@ void DumpImageBufferToTempFile( std::string filename, std::string targetFilename
   FILE* fp = fopen( filename.c_str() , "rb" );
   AutoCloseFile autoClose( fp );
 
-  Dali::Devel::PixelBuffer bitmap;
+  Dali::Integration::Bitmap* bitmap = Dali::Integration::Bitmap::New( Dali::Integration::Bitmap::BITMAP_2D_PACKED_PIXELS,  ResourcePolicy::OWNED_RETAIN );
+  Dali::Integration::BitmapPtr bitmapPtr( bitmap );
   const Dali::TizenPlatform::ImageLoader::Input input( fp );
 
-  DALI_TEST_CHECK( functions.loader( input, bitmap ) );
+  DALI_TEST_CHECK( functions.loader( input, *bitmap ) );
 
-  Dali::PixelBuffer* bufferPtr( bitmap.GetBuffer() );
+  Dali::PixelBuffer* bufferPtr( bitmapPtr->GetBuffer() );
 
   FILE* writeFp = fopen( targetFilename.c_str(), "wb" );
   AutoCloseFile autoCloseWrite( writeFp );
-  auto& impl = GetImplementation(bitmap);
-  fwrite( bufferPtr, 1, impl.GetBufferSize(), writeFp );
+  fwrite( bufferPtr, 1, bitmap->GetBufferSize(), writeFp );
 }
index 4c1d34d..fa7fa0d 100644 (file)
@@ -20,7 +20,6 @@
 
 #include <dali/dali.h>
 #include <dali/integration-api/bitmap.h>
-#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
 #include "platform-abstractions/tizen/image-loaders/image-loader-input.h"
 
 // Simple structure to close the file when finished with it.
@@ -83,7 +82,7 @@ private:
  */
 struct LoadFunctions
 {
-  typedef bool (*LoadBitmapFunction)( const Dali::TizenPlatform::ImageLoader::Input& input, Dali::Devel::PixelBuffer& );
+  typedef bool (*LoadBitmapFunction)( 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 );
index ec480f0..6301ad8 100644 (file)
@@ -358,13 +358,14 @@ void TestDownscaledBitmapHasRightDimensionsAndFormat(
   FittingMode::Type fittingMode( FittingMode::SHRINK_TO_FIT );
   SamplingMode::Type samplingMode( SamplingMode::BOX );
 
-  Dali::Devel::PixelBuffer sourceBitmap = Dali::Devel::PixelBuffer::New( sourceDimension, sourceDimension, format );
+  Integration::BitmapPtr sourceBitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
+  sourceBitmap->GetPackedPixelsProfile()->ReserveBuffer( format, sourceDimension, sourceDimension, sourceDimension, sourceDimension );
 
-  Dali::Devel::PixelBuffer downScaled = DownscaleBitmap( sourceBitmap, desired, fittingMode, samplingMode );
+  Integration::BitmapPtr downScaled = DownscaleBitmap( *sourceBitmap, desired, fittingMode, samplingMode );
 
-  DALI_TEST_EQUALS( downScaled.GetWidth(), expectedDimension, location );
-  DALI_TEST_EQUALS( downScaled.GetHeight(), expectedDimension, location );
-  DALI_TEST_EQUALS( downScaled.GetPixelFormat(), format, location );
+  DALI_TEST_EQUALS( downScaled->GetImageWidth(), expectedDimension, location );
+  DALI_TEST_EQUALS( downScaled->GetImageHeight(), expectedDimension, location );
+  DALI_TEST_EQUALS( downScaled->GetPixelFormat(), format, location );
 }
 
 /**
index ab074dd..477c1d4 100644 (file)
@@ -37,13 +37,13 @@ const char* ASCII_PAD_VALUE = ANSI_BLUE "#";
 typedef unsigned char PixelBuffer;
 
 
-void FillBitmap( Dali::Devel::PixelBuffer bitmap )
+void FillBitmap( BitmapPtr bitmap )
 {
   // Fill the given bitmap fully.
-  const Pixel::Format pixelFormat = bitmap.GetPixelFormat();
+  const Pixel::Format pixelFormat = bitmap->GetPixelFormat();
   const unsigned int bytesPerPixel = Pixel::GetBytesPerPixel( pixelFormat );
-  PixelBuffer * const targetPixels = bitmap.GetBuffer();
-  const int bytesToFill = bitmap.GetWidth() * bitmap.GetHeight() * bytesPerPixel;
+  PixelBuffer * const targetPixels = bitmap->GetBuffer();
+  const int bytesToFill = bitmap.Get()->GetImageWidth() * bitmap.Get()->GetImageHeight() * bytesPerPixel;
 
   memset( targetPixels, BORDER_FILL_VALUE, bytesToFill );
 }
@@ -97,15 +97,16 @@ void PerformFittingTests( TestContainer& tests )
     // Create a source bitmap.
     ImageDimensions desiredDimensions( desiredWidth, desiredHeight );
     SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR;
+    BitmapPtr sourceBitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
+    Integration::Bitmap::PackedPixelsProfile *packedView = sourceBitmap->GetPackedPixelsProfile();
+    const Pixel::Format pixelFormat = sourceBitmap->GetPixelFormat();
+    packedView->ReserveBuffer( pixelFormat, sourceWidth, sourceHeight, sourceWidth, sourceHeight );
 
-
-    auto sourceBitmap = Dali::Devel::PixelBuffer::New( sourceWidth, sourceHeight, Pixel::Format::RGBA8888 );
-    const Pixel::Format pixelFormat = sourceBitmap.GetPixelFormat();
     // Completely fill the source bitmap (with white).
     FillBitmap( sourceBitmap );
 
     // Perform fitting operations (this is the method we are testing).
-    auto newBitmap = ApplyAttributesToBitmap( sourceBitmap, desiredDimensions, fittingMode, samplingMode );
+    BitmapPtr newBitmap = ApplyAttributesToBitmap( sourceBitmap, desiredDimensions, fittingMode, samplingMode );
 
     DALI_TEST_CHECK( newBitmap );
 
@@ -115,16 +116,16 @@ void PerformFittingTests( TestContainer& tests )
       return;
     }
 
-    auto bitmap( newBitmap );
+    Bitmap *bitmap = newBitmap.Get();
 
-    unsigned int resultWidth = bitmap.GetWidth();
-    unsigned int resultHeight = bitmap.GetHeight();
+    unsigned int resultWidth = bitmap->GetImageWidth();
+    unsigned int resultHeight = bitmap->GetImageHeight();
 
     // Check the dimensions of the modified image match against the expected values defined in the test.
     DALI_TEST_EQUALS( resultWidth, test.expectedWidth, TEST_LOCATION );
     DALI_TEST_EQUALS( resultHeight, test.expectedHeight, TEST_LOCATION );
 
-    PixelBuffer* resultBuffer = bitmap.GetBuffer();
+    PixelBuffer* resultBuffer = bitmap->GetBuffer();
     const unsigned int bytesPerPixel = Pixel::GetBytesPerPixel( pixelFormat );
 
     // We generate an ASCII representation of the source, desired and result images to log, purely as a debugging aid.
index a1408ce..e9a94cc 100644 (file)
@@ -411,17 +411,30 @@ void CalculateBordersFromFittingMode(  ImageDimensions sourceSize, FittingMode::
 }
 
 /**
- * @brief Construct a pixel buffer object from a copy of the pixel array passed in.
+ * @brief Construct a bitmap with format and dimensions requested.
  */
-Dali::Devel::PixelBuffer MakePixelBuffer( const uint8_t * const pixels, Pixel::Format pixelFormat, unsigned int width, unsigned int height )
+BitmapPtr MakeEmptyBitmap( Pixel::Format pixelFormat, unsigned int width, unsigned int height )
+{
+  DALI_ASSERT_DEBUG( Pixel::GetBytesPerPixel(pixelFormat) && "Compressed formats not supported." );
+
+  // Allocate a pixel buffer to hold the image passed in:
+  Integration::BitmapPtr newBitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
+  newBitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, width, height, width, height );
+  return newBitmap;
+}
+
+/**
+ * @brief Construct a bitmap object from a copy of the pixel array passed in.
+ */
+BitmapPtr MakeBitmap( const uint8_t * const pixels, Pixel::Format pixelFormat, unsigned int width, unsigned int height )
 {
   DALI_ASSERT_DEBUG( pixels && "Null bitmap buffer to copy." );
 
   // Allocate a pixel buffer to hold the image passed in:
-  auto newBitmap = Dali::Devel::PixelBuffer::New( width, height, pixelFormat );
+  Integration::BitmapPtr newBitmap = MakeEmptyBitmap( pixelFormat, width, height );
 
   // Copy over the pixels from the downscaled image that was generated in-place in the pixel buffer of the input bitmap:
-  memcpy( newBitmap.GetBuffer(), pixels, width * height * Pixel::GetBytesPerPixel( pixelFormat ) );
+  memcpy( newBitmap->GetBuffer(), pixels, width * height * Pixel::GetBytesPerPixel( pixelFormat ) );
   return newBitmap;
 }
 
@@ -512,14 +525,14 @@ ImageDimensions CalculateDesiredDimensions( ImageDimensions rawDimensions, Image
  *   bitmaps dimensions to only be as large as necessary, as a memory saving optimization. This will cause
  *   GPU scaling to be performed at render time giving the same result with less texture traversal.
  *
- * @param[in] bitmap            The source pixel buffer to perform modifications on.
+ * @param[in] bitmap            The source bitmap to perform modifications on.
  * @param[in] desiredDimensions The target dimensions to aim to fill based on the fitting mode.
  * @param[in] fittingMode       The fitting mode to use.
  *
  * @return                      A new bitmap with the padding and cropping required for fitting mode applied.
  *                              If no modification is needed or possible, the passed in bitmap is returned.
  */
-Dali::Devel::PixelBuffer CropAndPadForFittingMode( Dali::Devel::PixelBuffer& bitmap, ImageDimensions desiredDimensions, FittingMode::Type fittingMode );
+Integration::BitmapPtr CropAndPadForFittingMode( Integration::BitmapPtr bitmap, ImageDimensions desiredDimensions, FittingMode::Type fittingMode );
 
 /**
  * @brief Adds horizontal or vertical borders to the source image.
@@ -531,34 +544,41 @@ Dali::Devel::PixelBuffer CropAndPadForFittingMode( Dali::Devel::PixelBuffer& bit
  */
 void AddBorders( PixelBuffer *targetPixels, const unsigned int bytesPerPixel, const ImageDimensions targetDimensions, const ImageDimensions padDimensions );
 
-Dali::Devel::PixelBuffer ApplyAttributesToBitmap( Dali::Devel::PixelBuffer bitmap, ImageDimensions dimensions, FittingMode::Type fittingMode, SamplingMode::Type samplingMode )
+BitmapPtr ApplyAttributesToBitmap( BitmapPtr bitmap, ImageDimensions dimensions, FittingMode::Type fittingMode, SamplingMode::Type samplingMode )
 {
   if( bitmap )
   {
     // Calculate the desired box, accounting for a possible zero component:
-    const ImageDimensions desiredDimensions  = CalculateDesiredDimensions( bitmap.GetWidth(), bitmap.GetHeight(), dimensions.GetWidth(), dimensions.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, fittingMode, samplingMode );
+    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.
     // Add crop and add borders if necessary depending on fitting mode.
-    if( bitmap )
+    if( bitmap && bitmap->GetPackedPixelsProfile() )
     {
       bitmap = CropAndPadForFittingMode( bitmap, desiredDimensions, fittingMode );
     }
+
+    // Examine the image pixels remaining after cropping and scaling to see if all
+    // are opaque, allowing faster rendering, or some have non-1.0 alpha:
+    if( bitmap && bitmap->GetPackedPixelsProfile() && Pixel::HasAlpha( bitmap->GetPixelFormat() ) )
+    {
+      bitmap->GetPackedPixelsProfile()->TestForTransparency();
+    }
   }
 
   return bitmap;
 }
 
-Dali::Devel::PixelBuffer CropAndPadForFittingMode( Dali::Devel::PixelBuffer& bitmap, ImageDimensions desiredDimensions, FittingMode::Type fittingMode )
+BitmapPtr CropAndPadForFittingMode( BitmapPtr bitmap, ImageDimensions desiredDimensions, FittingMode::Type fittingMode )
 {
-  const unsigned int inputWidth = bitmap.GetWidth();
-  const unsigned int inputHeight = bitmap.GetHeight();
+  const unsigned int inputWidth = bitmap->GetImageWidth();
+  const unsigned int inputHeight = bitmap->GetImageHeight();
 
   if( desiredDimensions.GetWidth() < 1u || desiredDimensions.GetHeight() < 1u )
   {
@@ -603,16 +623,18 @@ Dali::Devel::PixelBuffer CropAndPadForFittingMode( Dali::Devel::PixelBuffer& bit
         return bitmap;
       }
 
-      // Create new PixelBuffer with the desired size.
-      const auto pixelFormat = bitmap.GetPixelFormat();
-
-      auto croppedBitmap = Devel::PixelBuffer::New( desiredWidth, desiredHeight, pixelFormat );
+      // Create a new bitmap with the desired size.
+      BitmapPtr croppedBitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
+      Integration::Bitmap::PackedPixelsProfile *packedView = croppedBitmap->GetPackedPixelsProfile();
+      DALI_ASSERT_DEBUG( packedView );
+      const Pixel::Format pixelFormat = bitmap->GetPixelFormat();
+      packedView->ReserveBuffer( pixelFormat, desiredWidth, desiredHeight, desiredWidth, desiredHeight );
 
       // Add some pre-calculated offsets to the bitmap pointers so this is not done within a loop.
       // The cropping is added to the source pointer, and the padding is added to the destination.
-      const auto bytesPerPixel = Pixel::GetBytesPerPixel( pixelFormat );
-      const PixelBuffer * const sourcePixels = bitmap.GetBuffer() + ( ( ( ( scanlinesToCrop / 2 ) * inputWidth ) + ( columnsToCrop / 2 ) ) * bytesPerPixel );
-      PixelBuffer * const targetPixels = croppedBitmap.GetBuffer();
+      const unsigned int bytesPerPixel = Pixel::GetBytesPerPixel( pixelFormat );
+      const PixelBuffer * const sourcePixels = bitmap->GetBuffer() + ( ( ( ( scanlinesToCrop / 2 ) * inputWidth ) + ( columnsToCrop / 2 ) ) * bytesPerPixel );
+      PixelBuffer * const targetPixels = croppedBitmap->GetBuffer();
       PixelBuffer * const targetPixelsActive = targetPixels + ( ( ( ( scanlinesToPad / 2 ) * desiredWidth ) + ( columnsToPad / 2 ) ) * bytesPerPixel );
       DALI_ASSERT_DEBUG( sourcePixels && targetPixels );
 
@@ -640,7 +662,7 @@ Dali::Devel::PixelBuffer CropAndPadForFittingMode( Dali::Devel::PixelBuffer& bit
       // Add vertical or horizontal borders to the final image (if required).
       desiredDimensions.SetWidth( desiredWidth );
       desiredDimensions.SetHeight( desiredHeight );
-      AddBorders( croppedBitmap.GetBuffer(), bytesPerPixel, desiredDimensions, ImageDimensions( columnsToPad, scanlinesToPad ) );
+      AddBorders( croppedBitmap->GetBuffer(), bytesPerPixel, desiredDimensions, ImageDimensions( columnsToPad, scanlinesToPad ) );
       // Overwrite the loaded bitmap with the cropped version
       bitmap = croppedBitmap;
     }
@@ -697,26 +719,26 @@ void AddBorders( PixelBuffer *targetPixels, const unsigned int bytesPerPixel, co
   }
 }
 
-Dali::Devel::PixelBuffer DownscaleBitmap( Dali::Devel::PixelBuffer bitmap,
+Integration::BitmapPtr DownscaleBitmap( Integration::Bitmap& bitmap,
                                         ImageDimensions desired,
                                         FittingMode::Type fittingMode,
                                         SamplingMode::Type samplingMode )
 {
   // Source dimensions as loaded from resources (e.g. filesystem):
-  auto bitmapWidth  = bitmap.GetWidth();
-  auto bitmapHeight = bitmap.GetHeight();
+  const unsigned int bitmapWidth  = bitmap.GetImageWidth();
+  const unsigned int bitmapHeight = bitmap.GetImageHeight();
   // Desired dimensions (the rectangle to fit the source image to):
-  auto desiredWidth = desired.GetWidth();
-  auto desiredHeight = desired.GetHeight();
+  const unsigned int desiredWidth = desired.GetWidth();
+  const unsigned int desiredHeight = desired.GetHeight();
 
-  Dali::Devel::PixelBuffer outputBitmap { bitmap };
+  BitmapPtr outputBitmap( &bitmap );
 
   // If a different size than the raw one has been requested, resize the image:
-  if(
+  if( bitmap.GetPackedPixelsProfile() &&
       (desiredWidth > 0.0f) && (desiredHeight > 0.0f) &&
       ((desiredWidth < bitmapWidth) || (desiredHeight < bitmapHeight)) )
   {
-    auto pixelFormat = bitmap.GetPixelFormat();
+    const Pixel::Format pixelFormat = bitmap.GetPixelFormat();
 
     // 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;
@@ -734,17 +756,16 @@ Dali::Devel::PixelBuffer DownscaleBitmap( Dali::Devel::PixelBuffer bitmap,
       if( samplingMode == SamplingMode::LINEAR || samplingMode == SamplingMode::BOX_THEN_LINEAR ||
           samplingMode == SamplingMode::NEAREST || samplingMode == SamplingMode::BOX_THEN_NEAREST )
       {
-        outputBitmap = Dali::Devel::PixelBuffer::New( filteredWidth, filteredHeight, pixelFormat );
-
+        outputBitmap = MakeEmptyBitmap( pixelFormat, filteredWidth, filteredHeight );
         if( outputBitmap )
         {
           if( samplingMode == SamplingMode::LINEAR || samplingMode == SamplingMode::BOX_THEN_LINEAR )
           {
-            LinearSample( bitmap.GetBuffer(), ImageDimensions(shrunkWidth, shrunkHeight), pixelFormat, outputBitmap.GetBuffer(), filteredDimensions );
+            LinearSample( bitmap.GetBuffer(), ImageDimensions(shrunkWidth, shrunkHeight), pixelFormat, outputBitmap->GetBuffer(), filteredDimensions );
           }
           else
           {
-            PointSample( bitmap.GetBuffer(), shrunkWidth, shrunkHeight, pixelFormat, outputBitmap.GetBuffer(), filteredWidth, filteredHeight );
+            PointSample( bitmap.GetBuffer(), shrunkWidth, shrunkHeight, pixelFormat, outputBitmap->GetBuffer(), filteredWidth, filteredHeight );
           }
           filtered = true;
         }
@@ -753,7 +774,7 @@ Dali::Devel::PixelBuffer DownscaleBitmap( Dali::Devel::PixelBuffer bitmap,
     // Copy out the 2^x downscaled, box-filtered pixels if no secondary filter (point or linear) was applied:
     if( filtered == false && ( shrunkWidth < bitmapWidth || shrunkHeight < bitmapHeight ) )
     {
-      outputBitmap = MakePixelBuffer( bitmap.GetBuffer(), pixelFormat, shrunkWidth, shrunkHeight );
+      outputBitmap = MakeBitmap( bitmap.GetBuffer(), pixelFormat, shrunkWidth, shrunkHeight );
     }
   }
 
index b790da5..0c1e253 100644 (file)
 #include <dali/public-api/images/image-operations.h>
 #include <resampler.h>
 
-#ifdef DALI_ADAPTOR_COMPILATION
-#include <adaptors/devel-api/adaptor-framework/pixel-buffer.h>
-#else
-#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
-#endif
-
-
 namespace Dali
 {
 namespace Internal
@@ -87,16 +80,13 @@ ImageDimensions CalculateDesiredDimensions( ImageDimensions rawDimensions, Image
  *         bitmap passed-in, or the original bitmap passed in if the attributes
  *         have no effect.
  */
-Dali::Devel::PixelBuffer ApplyAttributesToBitmap( Dali::Devel::PixelBuffer bitmap, ImageDimensions dimensions, FittingMode::Type fittingMode = FittingMode::DEFAULT, SamplingMode::Type samplingMode = SamplingMode::DEFAULT );
+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.
  **/
-Dali::Devel::PixelBuffer DownscaleBitmap( Dali::Devel::PixelBuffer bitmap,
-                                          ImageDimensions desired,
-                                          FittingMode::Type fittingMode,
-                                          SamplingMode::Type samplingMode );
+Integration::BitmapPtr DownscaleBitmap( Integration::Bitmap& bitmap, ImageDimensions desired, FittingMode::Type fittingMode, SamplingMode::Type samplingMode );
 /**@}*/
 
 /**
index d7a6da1..16a012e 100644 (file)
@@ -17,8 +17,8 @@
 #include "image-loader.h"
 
 #include <dali/devel-api/common/ref-counted-dali-vector.h>
-#include <adaptors/common/pixel-buffer-impl.h>
-
+#include <dali/integration-api/bitmap.h>
+#include <dali/integration-api/debug.h>
 
 #include "loader-astc.h"
 #include "loader-bmp.h"
@@ -29,6 +29,7 @@
 #include "loader-png.h"
 #include "loader-wbmp.h"
 #include "image-operations.h"
+#include "image-loader-input.h"
 #include "portable/file-reader.h"
 
 using namespace Dali::Integration;
@@ -40,7 +41,7 @@ namespace TizenPlatform
 
 namespace
 {
-typedef bool (*LoadBitmapFunction)( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& pixelData );
+typedef bool (*LoadBitmapFunction)( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 typedef bool (*LoadBitmapHeaderFunction)( const ImageLoader::Input& input, unsigned int& width, unsigned int& height );
 
 #if defined(DEBUG_ENABLED)
@@ -251,17 +252,17 @@ bool GetBitmapLoaderFunctions( FILE *fp,
 namespace ImageLoader
 {
 
-bool ConvertStreamToBitmap( const BitmapResourceType& resource, std::string path, FILE * const fp, Dali::Devel::PixelBuffer& pixelBuffer )
+bool ConvertStreamToBitmap( const BitmapResourceType& resource, std::string path, FILE * const fp, BitmapPtr& ptr )
 {
   DALI_LOG_TRACE_METHOD( gLogFilter );
 
   bool result = false;
+  BitmapPtr bitmap = 0;
 
   if (fp != NULL)
   {
     LoadBitmapFunction function;
     LoadBitmapHeaderFunction header;
-
     Bitmap::Profile profile;
 
     if ( GetBitmapLoaderFunctions( fp,
@@ -270,19 +271,22 @@ bool ConvertStreamToBitmap( const BitmapResourceType& resource, std::string path
                                    header,
                                    profile ) )
     {
+      bitmap = Bitmap::New( profile, ResourcePolicy::OWNED_DISCARD );
+
+      DALI_LOG_SET_OBJECT_STRING( bitmap, path );
       const ScalingParameters scalingParameters( resource.size, resource.scalingMode, resource.samplingMode );
       const ImageLoader::Input input( fp, scalingParameters, resource.orientationCorrection );
 
       // Run the image type decoder:
-      result = function( input, pixelBuffer );
+      result = function( input, *bitmap );
 
       if (!result)
       {
         DALI_LOG_WARNING( "Unable to convert %s\n", path.c_str() );
-        pixelBuffer.Reset();
+        bitmap = 0;
       }
 
-      pixelBuffer = Internal::Platform::ApplyAttributesToBitmap( pixelBuffer, resource.size, resource.scalingMode, resource.samplingMode );
+      bitmap = Internal::Platform::ApplyAttributesToBitmap( bitmap, resource.size, resource.scalingMode, resource.samplingMode );
     }
     else
     {
@@ -290,40 +294,23 @@ bool ConvertStreamToBitmap( const BitmapResourceType& resource, std::string path
     }
   }
 
+  ptr.Reset( bitmap.Get() );
   return result;
 }
 
 ResourcePointer LoadImageSynchronously( const Integration::BitmapResourceType& resource, const std::string& path )
 {
   ResourcePointer result;
-  Dali::Devel::PixelBuffer bitmap;
+  BitmapPtr bitmap = 0;
 
   Internal::Platform::FileReader fileReader( path );
   FILE * const fp = fileReader.GetFile();
   if( fp != NULL )
   {
-    bool success = ConvertStreamToBitmap(resource, path, fp, bitmap);
-    if (success && bitmap)
+    bool success = ConvertStreamToBitmap( resource, path, fp, bitmap );
+    if( success && bitmap )
     {
-      Bitmap::Profile profile{Bitmap::Profile::BITMAP_2D_PACKED_PIXELS};
-
-      // For backward compatibility the Bitmap must be created
-      auto retval = Bitmap::New(profile, Dali::ResourcePolicy::OWNED_DISCARD);
-
-      DALI_LOG_SET_OBJECT_STRING( retval, path );
-
-      retval->GetPackedPixelsProfile()->ReserveBuffer(
-              bitmap.GetPixelFormat(),
-              bitmap.GetWidth(),
-              bitmap.GetHeight(),
-              bitmap.GetWidth(),
-              bitmap.GetHeight()
-            );
-
-      auto& impl = Dali::GetImplementation(bitmap);
-
-      std::copy( impl.GetBuffer(), impl.GetBuffer()+impl.GetBufferSize(), retval->GetBuffer());
-      result.Reset(retval);
+      result.Reset(bitmap.Get());
     }
   }
   return result;
index d619a30..15469ba 100644 (file)
@@ -21,9 +21,6 @@
 #include <dali/public-api/images/image-operations.h>
 #include <dali/integration-api/resource-types.h>
 #include <dali/integration-api/bitmap.h>
-#include <dali/public-api/images/pixel-data.h>
-#include <adaptors/devel-api/adaptor-framework/pixel-buffer.h>
-#include <string>
 
 namespace Dali
 {
@@ -44,16 +41,16 @@ namespace ImageLoader
  * @param[out] bitmap Pointer to write bitmap to
  * @return true on success, false on failure
  */
-bool ConvertStreamToBitmap( const Integration::BitmapResourceType& resource, std::string path, FILE * const fp, Dali::Devel::PixelBuffer& pixelBuffer );
+bool ConvertStreamToBitmap( const Integration::BitmapResourceType& resource, std::string path, FILE * const fp, Integration::BitmapPtr& ptr );
 
 /**
  * Convert a bitmap and write to a file stream.
  * @param[in] path The path to the resource.
  * @param[in] fp File Pointer. Closed on exit.
- * @param[out] pixelData Reference to PixelData object.
+ * @param[out] bitmap Pointer from which to read bitmap
  * @return true on success, false on failure
  */
-bool ConvertBitmapToStream( std::string path, FILE * const fp, Dali::Devel::PixelBuffer& pixelBuffer );
+bool ConvertBitmapToStream( std::string path, FILE * const fp, Integration::BitmapPtr& ptr );
 
 /**
  * Loads an image synchronously
index a0362aa..bddf954 100755 (executable)
 #include "loader-astc.h"
 
 // EXTERNAL INCLUDES
+#include <cstdio>
+#include <cstdlib>
 #include <cstring>
+#include <stdint.h>
 #include <dali/public-api/common/compile-time-assert.h>
 #include <dali/integration-api/debug.h>
+#include <dali/integration-api/bitmap.h>
 #include <dali/public-api/images/pixel.h>
-#include <adaptors/devel-api/adaptor-framework/pixel-buffer.h>
 
 namespace Dali
 {
+using Integration::Bitmap;
+using Dali::Integration::PixelBuffer;
+
 namespace TizenPlatform
 {
+
 namespace
 {
 
@@ -167,7 +174,7 @@ bool LoadAstcHeader( const ImageLoader::Input& input, unsigned int& width, unsig
 }
 
 // File loading API entry-point:
-bool LoadBitmapFromAstc( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+bool LoadBitmapFromAstc( const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   FILE* const filePointer = input.file;
   if( !filePointer )
@@ -224,13 +231,16 @@ bool LoadBitmapFromAstc( const ImageLoader::Input& input, Dali::Devel::PixelBuff
     return false;
   }
 
-  // allocate pixel data
-  bitmap = Dali::Devel::PixelBuffer::New(width, height, pixelFormat);
-  auto pixels = bitmap.GetBuffer();
+  // Allocate space to load the image data in to.
+  PixelBuffer* const pixels = bitmap.GetCompressedProfile()->ReserveBufferOfSize( pixelFormat, width, height, imageByteCount );
+  if( !pixels )
+  {
+    DALI_LOG_ERROR( "Unable to reserve a pixel buffer to load the requested bitmap into.\n" );
+    return false;
+  }
 
   // Load the image data.
   const size_t bytesRead = fread( pixels, 1, imageByteCount, filePointer );
-
   // Check the size of loaded data is what we expected.
   if( bytesRead != imageByteCount )
   {
index f5cf6b4..cb50b93 100644 (file)
 
 namespace Dali
 {
-namespace Devel
+
+namespace Integration
 {
-class PixelBuffer;
+  class Bitmap;
 }
 
-
 namespace TizenPlatform
 {
 
@@ -49,7 +49,7 @@ const unsigned char MAGIC_BYTE_2 = 0xAB;
  * @param[out] bitmap The bitmap class where the decoded image will be stored
  * @return True if file loaded successfully, false otherwise
  */
-bool LoadBitmapFromAstc( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap );
+bool LoadBitmapFromAstc( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * Loads the header of a ASTC file and fills in the width and height appropriately.
index 72799b5..fdd0837 100644 (file)
 #include "loader-bmp.h"
 
 #include <dali/public-api/common/vector-wrapper.h>
-#include <adaptors/devel-api/adaptor-framework/pixel-buffer.h>
 #include <dali/integration-api/debug.h>
+#include <dali/integration-api/bitmap.h>
+
+#include <cstdlib>
 
 namespace Dali
 {
-
+using Integration::Bitmap;
+using Dali::Integration::PixelBuffer;
 namespace TizenPlatform
 {
 
@@ -127,7 +130,7 @@ bool LoadBmpHeader(FILE *fp, unsigned int &width, unsigned int &height, BmpFileH
  * @return true, if decode successful, false otherwise
  */
 bool DecodeRGB24V5(FILE *fp,
-                   unsigned char* pixels,
+                   PixelBuffer *pixels,
                    unsigned int width,
                    unsigned int height,
                    unsigned int offset,
@@ -148,7 +151,7 @@ bool DecodeRGB24V5(FILE *fp,
 
   for(unsigned int yPos = 0; yPos < height; yPos ++)
   {
-    unsigned char* pixelsPtr = NULL;
+    PixelBuffer *pixelsPtr = NULL;
     if(topDown)
     {
       pixelsPtr = pixels + ( yPos * rowStride);
@@ -194,7 +197,7 @@ bool DecodeRGB24V5(FILE *fp,
  * @return true, if decode successful, false otherwise
  */
 bool DecodeBF32V4(FILE *fp,
-                  unsigned char* pixels,
+                  PixelBuffer *pixels,
                   unsigned int width,
                   unsigned int height,
                   unsigned int offset,
@@ -215,7 +218,7 @@ bool DecodeBF32V4(FILE *fp,
 
   for(unsigned int yPos = 0; yPos < height; yPos ++)
   {
-    unsigned char* pixelsPtr = NULL;
+    PixelBuffer *pixelsPtr = NULL;
     if(topDown)
     {
       pixelsPtr = pixels + ( yPos * rowStride);
@@ -261,7 +264,7 @@ bool DecodeBF32V4(FILE *fp,
  * @return true, if decode successful, false otherwise
  */
 bool DecodeBF32(FILE *fp,
-                unsigned char* pixels,
+                PixelBuffer *pixels,
                 unsigned int width,
                 unsigned int height,
                 unsigned int offset,
@@ -282,7 +285,7 @@ bool DecodeBF32(FILE *fp,
 
   for (unsigned int yPos = 0; yPos < height; yPos++)
   {
-    unsigned char* pixelsPtr;
+    PixelBuffer *pixelsPtr;
     if (topDown)
     {
       // the data in the file is top down, and we store the data top down
@@ -329,7 +332,7 @@ bool DecodeBF32(FILE *fp,
  * @return true, if decode successful, false otherwise
  */
 bool DecodeBF565(FILE *fp,
-                 unsigned char* pixels,
+                 PixelBuffer *pixels,
                  unsigned int width,
                  unsigned int height,
                  unsigned int offset,
@@ -351,7 +354,7 @@ bool DecodeBF565(FILE *fp,
 
   for(unsigned int i = 0; i < height; i++)
   {
-    unsigned char* pixelsPtr = NULL;
+    PixelBuffer *pixelsPtr = NULL;
     if (topDown)
     {
       // the data in the file is top down, and we store the data top down
@@ -382,7 +385,7 @@ bool DecodeBF565(FILE *fp,
  * @return true, if decode successful, false otherwise
  */
 bool DecodeBF555(FILE *fp,
-                 unsigned char* pixels,
+                 PixelBuffer *pixels,
                  unsigned int width,
                  unsigned int height,
                  unsigned int offset,
@@ -418,7 +421,7 @@ bool DecodeBF555(FILE *fp,
 
   for (unsigned int yPos = 0; yPos < height; yPos++)
   {
-    unsigned char* pixelsPtr = NULL;
+    PixelBuffer *pixelsPtr = NULL;
     if (topDown)
     {
       // the data in the file is top down, and we store the data top down
@@ -452,7 +455,7 @@ bool DecodeBF555(FILE *fp,
  * @return true, if decode successful, false otherwise
  */
 bool DecodeRGB555(FILE *fp,
-                  unsigned char* pixels,
+                  PixelBuffer *pixels,
                   unsigned int width,
                   unsigned int height,
                   unsigned int offset,
@@ -485,7 +488,7 @@ bool DecodeRGB555(FILE *fp,
   }
   for(unsigned int i = 0; i < height; i++)
   {
-    unsigned char* pixelsPtr = NULL;
+    PixelBuffer *pixelsPtr = NULL;
     if (topDown)
     {
       // the data in the file is top down, and we store the data top down
@@ -519,7 +522,7 @@ bool DecodeRGB555(FILE *fp,
  * @return true, if decode successful, false otherwise
  */
 bool DecodeRGB1(FILE *fp,
-                unsigned char* pixels,
+                PixelBuffer *pixels,
                 unsigned int width,
                 unsigned int height,
                 unsigned int offset,
@@ -567,7 +570,7 @@ bool DecodeRGB1(FILE *fp,
 
   for(unsigned int index = 0; index < height; index = index + 1)
   {
-    unsigned char* pixelsPtr = NULL;
+    PixelBuffer *pixelsPtr = NULL;
     if (topDown)
     {
       // the data in the file is top down, and we store the data top down
@@ -612,7 +615,7 @@ bool DecodeRGB1(FILE *fp,
  * @return true, if decode successful, false otherwise
  */
 bool DecodeRGB4(FILE *fp,
-                unsigned char* pixels,
+                PixelBuffer *pixels,
                 unsigned int width,
                 unsigned int height,
                 unsigned int offset,
@@ -654,7 +657,7 @@ bool DecodeRGB4(FILE *fp,
 
   for(unsigned int index = 0; index < height; index = index + 1)
   {
-    unsigned char* pixelsPtr = NULL;
+    PixelBuffer *pixelsPtr = NULL;
     if (topDown)
     {
       // the data in the file is top down, and we store the data top down
@@ -688,7 +691,7 @@ bool DecodeRGB4(FILE *fp,
  * @return true, if decode successful, false otherwise
  */
 bool DecodeRGB8(FILE *fp,
-                unsigned char* pixels,
+                PixelBuffer *pixels,
                 unsigned int width,
                 unsigned int height,
                 unsigned int offset,
@@ -727,7 +730,7 @@ bool DecodeRGB8(FILE *fp,
   unsigned int ctIndex = 0;
   for(unsigned int index = 0; index < height; index = index + 1)
   {
-    unsigned char* pixelsPtr = NULL;
+    PixelBuffer *pixelsPtr = NULL;
     if (topDown)
     {
       // the data in the file is top down, and we store the data top down
@@ -760,7 +763,7 @@ bool DecodeRGB8(FILE *fp,
  * @return true, if decode successful, false otherwise
  */
 bool DecodeRLE4(FILE *fp,
-                unsigned char* pixels,
+                PixelBuffer *pixels,
                 unsigned int width,
                 unsigned int height,
                 unsigned int offset,
@@ -771,7 +774,7 @@ bool DecodeRLE4(FILE *fp,
     DALI_LOG_ERROR("Error decoding BMP_RLE4 format\n");
     return false;
   }
-  unsigned char* pixelsPtr = pixels;
+  PixelBuffer *pixelsPtr = pixels;
   width = ((width & 3) != 0) ? width + 4 - (width & 3) : width;
   char cmd[2];
   unsigned int cmdStride = 2;
@@ -928,7 +931,7 @@ bool DecodeRLE4(FILE *fp,
  * @return true, if decode successful, false otherwise
  */
 bool DecodeRLE8(FILE *fp,
-                unsigned char* pixels,
+                PixelBuffer *pixels,
                 unsigned int width,
                 unsigned int height,
                 unsigned int offset,
@@ -939,7 +942,7 @@ bool DecodeRLE8(FILE *fp,
     DALI_LOG_ERROR("Error decoding BMP_RLE8 format\n");
     return false;
   }
-  unsigned char* pixelsPtr = pixels;
+  PixelBuffer *pixelsPtr = pixels;
   unsigned int x = 0;
   unsigned int y = 0;
   unsigned int cmdStride = 2;
@@ -1053,9 +1056,9 @@ bool LoadBmpHeader( const ImageLoader::Input& input, unsigned int& width, unsign
   return ret;
 }
 
-bool LoadBitmapFromBmp( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+bool LoadBitmapFromBmp( 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)
   {
@@ -1196,11 +1199,9 @@ bool LoadBitmapFromBmp( const ImageLoader::Input& input, Dali::Devel::PixelBuffe
     padding = 4 - padding;
   }
 
+  PixelBuffer *pixels =  NULL;
   int imageW = infoHeader.width;
-  int pixelBufferW = infoHeader.width;
-  int pixelBufferH = infoHeader.height;
-  auto newPixelFormat = Pixel::Format::INVALID;
-
+  int pixelBufferW = 0;
   switch(customizedFormat)
   {
   case BMP_RLE8:
@@ -1211,35 +1212,35 @@ bool LoadBitmapFromBmp( const ImageLoader::Input& input, Dali::Devel::PixelBuffe
   case BMP_BITFIELDS555:
   {
     pixelBufferW = ((imageW & 3) != 0) ? imageW + 4 - (imageW & 3) : imageW;
-    pixelBufferH = abs(infoHeader.height);
-    newPixelFormat = Pixel::RGB888;
+    pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGB888, pixelBufferW, abs(infoHeader.height));
     break;
   }
   case BMP_RGB1:
   {
     pixelBufferW = ((imageW & 63) != 0) ? imageW + 64 - (imageW & 63) : imageW;
-    pixelBufferH = abs(infoHeader.height);
-    newPixelFormat = Pixel::RGB888;
+    pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGB888, pixelBufferW, abs(infoHeader.height));
     break;
   }
   case BMP_BITFIELDS32:
   case BMP_BITFIELDS32V4:
   {
-    pixelBufferH = abs(infoHeader.height);
-    newPixelFormat = Pixel::RGB8888;
+    pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGB8888, infoHeader.width, abs(infoHeader.height));
     break;
   }
   case BMP_RGB24V5:
   {
-    newPixelFormat = Pixel::RGB888;
+    pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGB888, infoHeader.width, infoHeader.height);
     break;
   }
   default:
     if(pixelFormat == Pixel::RGB565 )
     {
       pixelBufferW = ((imageW & 3) != 0) ? imageW + 4 - (imageW & 3) : imageW;
-      pixelBufferH = abs(infoHeader.height);
-      newPixelFormat = Pixel::RGB565;
+      pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGB565, pixelBufferW, abs(infoHeader.height));
+    }
+    else
+    {
+      pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer(pixelFormat, infoHeader.width, infoHeader.height);
     }
     else
     {
@@ -1250,12 +1251,10 @@ bool LoadBitmapFromBmp( const ImageLoader::Input& input, Dali::Devel::PixelBuffe
     break;
   }
 
-  bitmap = Dali::Devel::PixelBuffer::New(pixelBufferW, pixelBufferH, newPixelFormat);
-  auto pixels = bitmap.GetBuffer();
+  // TODO: Add scaling support
 
   // Read the raw bitmap data
-  decltype(pixels) pixelsIterator = nullptr;
-
+  PixelBuffer *pixelsPtr;
   bool decodeResult(false);
   switch(customizedFormat)
   {
@@ -1322,15 +1321,15 @@ bool LoadBitmapFromBmp( const ImageLoader::Input& input, Dali::Devel::PixelBuffe
           if (topDown)
           {
             // the data in the file is top down, and we store the data top down
-            pixelsIterator = pixels + ( yPos * rowStride);
+            pixelsPtr = pixels + ( yPos * rowStride);
           }
           else
           {
             // the data in the file is bottom up, and we store the data top down
-            pixelsIterator = pixels + (((height-1)-yPos) * rowStride);
+            pixelsPtr = pixels + (((height-1)-yPos) * rowStride);
           }
 
-          if (fread(pixelsIterator, 1, rowStride, fp) != rowStride)
+          if (fread(pixelsPtr, 1, rowStride, fp) != rowStride)
           {
             DALI_LOG_ERROR("Error reading the BMP image\n");
             break;
@@ -1342,9 +1341,9 @@ bool LoadBitmapFromBmp( const ImageLoader::Input& input, Dali::Devel::PixelBuffe
           {
             for(unsigned int i = 0; i < rowStride; i += 3)
             {
-              unsigned char temp = pixelsIterator[i];
-              pixelsIterator[i] = pixelsIterator[i+2];
-              pixelsIterator[i+2] = temp;
+              unsigned char temp = pixelsPtr[i];
+              pixelsPtr[i] = pixelsPtr[i+2];
+              pixelsPtr[i+2] = temp;
             }
           }
 
index bb781db..5328632 100644 (file)
 
 namespace Dali
 {
-namespace Devel
+
+namespace Integration
 {
-class PixelBuffer;
+class Bitmap;
 }
 
-
 namespace TizenPlatform
 {
 
@@ -47,7 +47,7 @@ const unsigned char MAGIC_BYTE_2 = 0x4D;
  * @param[out] bitmap The bitmap class where the decoded image will be stored
  * @return  true if file decoded successfully, false otherwise
  */
-bool LoadBitmapFromBmp( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap );
+bool LoadBitmapFromBmp( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * Loads the header of a BMP file and fills in the width and height appropriately.
index 9bcd17b..1891eb1 100644 (file)
 #include "loader-gif.h"
 
 #include <gif_lib.h>
+#include <cstdlib>
 
 #include <dali/integration-api/debug.h>
-#include <adaptors/devel-api/adaptor-framework/pixel-buffer.h>
-#include <memory>
+#include <dali/integration-api/bitmap.h>
 
 // We need to check if giflib has the new open and close API (including error parameter).
 #ifdef GIFLIB_MAJOR
@@ -30,6 +30,8 @@
 
 namespace Dali
 {
+using Integration::Bitmap;
+using Dali::Integration::PixelBuffer;
 
 namespace TizenPlatform
 {
@@ -67,6 +69,22 @@ struct AutoCleanupGif
   GifFileType*& gifInfo;
 };
 
+// Simple class to enforce clean-up of PixelBuffer
+struct AutoDeleteBuffer
+{
+  AutoDeleteBuffer( PixelBuffer* _buffer )
+  : buffer( _buffer )
+  {
+  }
+
+  ~AutoDeleteBuffer()
+  {
+    delete []buffer;
+  }
+
+  PixelBuffer* buffer;
+};
+
 // Used in the GIF interlace algorithm to determine the starting byte and the increment required
 // for each pass.
 struct InterlacePair
@@ -122,7 +140,7 @@ bool LoadGifHeader(FILE *fp, unsigned int &width, unsigned int &height, GifFileT
 }
 
 /// Decode the GIF image.
-bool DecodeImage( GifFileType* gifInfo, unsigned char* decodedData, const unsigned int width, const unsigned int height, const unsigned int bytesPerRow )
+bool DecodeImage( GifFileType* gifInfo, PixelBuffer* decodedData, const unsigned int width, const unsigned int height, const unsigned int bytesPerRow )
 {
   if ( gifInfo->Image.Interlace )
   {
@@ -133,7 +151,7 @@ bool DecodeImage( GifFileType* gifInfo, unsigned char* decodedData, const unsign
     {
       for( unsigned int currentByte = interlacePairPtr->startingByte; currentByte < height; currentByte += interlacePairPtr->incrementalByte )
       {
-        unsigned char* row = decodedData + currentByte * bytesPerRow;
+        PixelBuffer* row = decodedData + currentByte * bytesPerRow;
         if ( DGifGetLine( gifInfo, row, width ) == GIF_ERROR )
         {
           DALI_LOG_ERROR( "GIF Loader: Error reading Interlaced GIF\n" );
@@ -145,7 +163,7 @@ bool DecodeImage( GifFileType* gifInfo, unsigned char* decodedData, const unsign
   else
   {
     // Non-interlace does not require any erratic reading / jumping.
-    unsigned char* decodedDataPtr( decodedData );
+    PixelBuffer* decodedDataPtr( decodedData );
 
     for ( unsigned int row = 0; row < height; ++row )
     {
@@ -177,7 +195,7 @@ GifColorType* GetImageColors( SavedImage* image, GifFileType* gifInfo )
 }
 
 /// Called when we want to handle IMAGE_DESC_RECORD_TYPE
-bool HandleImageDescriptionRecordType( Dali::Devel::PixelBuffer& bitmap, 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 )
   {
@@ -192,22 +210,17 @@ bool HandleImageDescriptionRecordType( Dali::Devel::PixelBuffer& bitmap, GifFile
     return false;
   }
 
-  Pixel::Format pixelFormat( Pixel::RGB888 );
-
   SavedImage* image( &gifInfo->SavedImages[ gifInfo->ImageCount - 1 ] );
   const GifImageDesc& desc( image->ImageDesc );
 
-  auto decodedData = new unsigned char[ width * height * sizeof( GifPixelType ) ];
-
-  std::unique_ptr<unsigned char[]> ptr{ decodedData };
+  // Create a buffer to store the decoded data.
+  PixelBuffer* decodedData( new PixelBuffer[ width * height * sizeof( GifPixelType ) ] );
+  AutoDeleteBuffer autoDeleteBuffer( decodedData );
 
   const unsigned int bytesPerRow( width * sizeof( GifPixelType ) );
   const unsigned int actualWidth( desc.Width );
   const unsigned int actualHeight( desc.Height );
 
-  // Create a buffer to store the decoded data.
-  bitmap = Dali::Devel::PixelBuffer::New( actualWidth, actualHeight, pixelFormat );
-
   // Decode the GIF Image
   if ( !DecodeImage( gifInfo, decodedData, actualWidth, actualHeight, bytesPerRow ) )
   {
@@ -220,7 +233,10 @@ bool HandleImageDescriptionRecordType( Dali::Devel::PixelBuffer& bitmap, GifFile
   // If it's an animated GIF, we still only read the first image
 
   // Create and populate pixel buffer.
-  auto pixels = bitmap.GetBuffer();
+
+  Pixel::Format pixelFormat( Pixel::RGB888 );
+  PixelBuffer *pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, actualWidth, actualHeight );
+
   for (unsigned int row = 0; row < actualHeight; ++row)
   {
     for (unsigned int column = 0; column < actualWidth; ++column)
@@ -233,7 +249,9 @@ bool HandleImageDescriptionRecordType( Dali::Devel::PixelBuffer& bitmap, GifFile
       pixels += 3;
     }
   }
+
   finished = true;
+
   return true;
 }
 
@@ -280,7 +298,7 @@ bool LoadGifHeader( const ImageLoader::Input& input, unsigned int& width, unsign
   return LoadGifHeader(fp, width, height, &gifInfo);
 }
 
-bool LoadBitmapFromGif( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+bool LoadBitmapFromGif( const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   FILE* const fp = input.file;
   // Load the GIF Header file.
index e637ac1..59d2591 100644 (file)
 
 namespace Dali
 {
-namespace Devel
+
+namespace Integration
 {
-class PixelBuffer;
+  class Bitmap;
 }
 
-
 namespace TizenPlatform
 {
 
@@ -48,7 +48,7 @@ const unsigned char MAGIC_BYTE_2 = 0x49;
  * @param[out] bitmap The bitmap class where the decoded image will be stored
  * @return  true if file decoded successfully, false otherwise
  */
-bool LoadBitmapFromGif( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap );
+bool LoadBitmapFromGif( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * Loads the header of a GIF file and fills in the width and height appropriately.
index 5078e8c..4a46931 100644 (file)
 
 // INTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
-#include <adaptors/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/integration-api/bitmap.h>
 
 namespace Dali
 {
+using Integration::Bitmap;
+using Dali::Integration::PixelBuffer;
 
 namespace TizenPlatform
 {
@@ -355,7 +357,7 @@ bool LoadIcoHeader( const ImageLoader::Input& input, unsigned int& width, unsign
   return true;
 }
 
-bool LoadBitmapFromIco( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+bool LoadBitmapFromIco( const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   IcoData chosen;
   Dali::Vector<unsigned char> map;
@@ -378,6 +380,7 @@ bool LoadBitmapFromIco( const ImageLoader::Input& input, Dali::Devel::PixelBuffe
 
   int diff_size = 0;
   unsigned int* pix;
+  PixelBuffer* pixels = NULL;
 
   size_t position = chosen.bmoffset;//22 == position
 
@@ -661,8 +664,7 @@ bool LoadBitmapFromIco( const ImageLoader::Input& input, Dali::Devel::PixelBuffe
     }
   }
 
-  bitmap = Dali::Devel::PixelBuffer::New(w, h, Pixel::Format::RGBA8888);
-  auto pixels = bitmap.GetBuffer();
+  pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, w, h );
   memcpy( pixels, &surface[0], w * h * 4 );
 
   return true;
index 1c845d5..3d9adb5 100644 (file)
 
 namespace Dali
 {
-namespace Devel
+
+namespace Integration
 {
-class PixelBuffer;
+  class Bitmap;
 }
 
 namespace TizenPlatform
@@ -44,7 +45,7 @@ const unsigned char MAGIC_BYTE_2 = 0x00;
  * @param[out] bitmap The bitmap class where the decoded image will be stored
  * @return  true if file decoded successfully, false otherwise
  */
-bool LoadBitmapFromIco( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap );
+bool LoadBitmapFromIco( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * @param[in]  input  Information about the input image (including file pointer)
index 3141c91..ea02893 100755 (executable)
 #include <cstring>
 #include <setjmp.h>
 
-#include <dali/public-api/object/property-map.h>
-#include <dali/public-api/object/property-array.h>
-#include <adaptors/devel-api/adaptor-framework/pixel-buffer.h>
-
+#include <dali/integration-api/bitmap.h>
 
 // INTERNAL HEADERS
 #include "platform-capabilities.h"
 #include "image-operations.h"
 #include <image-loading.h>
-#include <adaptors/common/pixel-buffer-impl.h>
 
 namespace
 {
+using Dali::Integration::Bitmap;
+using Dali::Integration::PixelBuffer;
 using Dali::Vector;
 namespace Pixel = Dali::Pixel;
-using PixelArray = unsigned char*;
+
+
 const unsigned int DECODED_L8 = 1;
 const unsigned int DECODED_RGB888 = 3;
 const unsigned int DECODED_RGBA8888 = 4;
@@ -173,7 +172,7 @@ UniquePointerSetter<T, Deleter> SetPointer(std::unique_ptr<T, Deleter>& uniquePo
   return UniquePointerSetter<T, Deleter>{uniquePointer};
 }
 
-using TransformFunction = std::function<void(PixelArray,unsigned, unsigned)>;
+using TransformFunction = std::function<void(PixelBuffer*,unsigned, unsigned)>;
 using TransformFunctionArray = std::array<TransformFunction, 3>; // 1, 3 and 4 bytes per pixel
 
 /// @brief Select the transform function depending on the pixel format
@@ -210,94 +209,9 @@ TransformFunction GetTransformFunction(const TransformFunctionArray& functions,
   return function;
 }
 
-// Storing Exif fields as properties
-template<class R, class V>
-R ConvertExifNumeric( const ExifEntry& entry )
-{
-  return static_cast<R>((*reinterpret_cast<V*>(entry.data)));
-}
-
-void AddExifFieldPropertyMap( Dali::Property::Map& out, const ExifEntry& entry, ExifIfd ifd )
-{
-  auto shortName = std::string(exif_tag_get_name_in_ifd(entry.tag, ifd ));
-  switch( entry.format )
-  {
-    case EXIF_FORMAT_ASCII:
-    {
-      out.Insert( shortName, std::string(reinterpret_cast<char *>(entry.data)) );
-      break;
-    }
-    case EXIF_FORMAT_SHORT:
-    {
-      out.Insert( shortName, ConvertExifNumeric<int, unsigned int>(entry) );
-      break;
-    }
-    case EXIF_FORMAT_LONG:
-    {
-      out.Insert( shortName, ConvertExifNumeric<int, unsigned long>(entry) );
-      break;
-    }
-    case EXIF_FORMAT_SSHORT:
-    {
-      out.Insert( shortName, ConvertExifNumeric<int, int>(entry) );
-      break;
-    }
-    case EXIF_FORMAT_SLONG:
-    {
-      out.Insert( shortName, ConvertExifNumeric<int, long>(entry) );
-      break;
-    }
-    case EXIF_FORMAT_FLOAT:
-    {
-      out.Insert (shortName, ConvertExifNumeric<float, float>(entry) );
-      break;
-    }
-    case EXIF_FORMAT_DOUBLE:
-    {
-      out.Insert( shortName, ConvertExifNumeric<float, double>(entry) );
-      break;
-    }
-    case EXIF_FORMAT_RATIONAL:
-    {
-      auto values = reinterpret_cast<unsigned int*>( entry.data );
-      Dali::Property::Array array;
-      array.Add( static_cast<int>(values[0]) );
-      array.Add( static_cast<int>(values[1]) );
-      out.Insert(shortName, array);
-      break;
-    }
-    case EXIF_FORMAT_SBYTE:
-    {
-      out.Insert(shortName, "EXIF_FORMAT_SBYTE Unsupported");
-      break;
-    }
-    case EXIF_FORMAT_BYTE:
-    {
-      out.Insert(shortName, "EXIF_FORMAT_BYTE Unsupported");
-      break;
-    }
-    case EXIF_FORMAT_SRATIONAL:
-    {
-      auto values = reinterpret_cast<int*>( entry.data );
-      Dali::Property::Array array;
-      array.Add(values[0]);
-      array.Add(values[1]);
-      out.Insert(shortName, array);
-      break;
-    }
-    case EXIF_FORMAT_UNDEFINED:
-    default:
-    {
-      std::stringstream ss;
-      ss << "EXIF_FORMAT_UNDEFINED, size: " << entry.size << ", components: " << entry.components;
-      out.Insert( shortName, ss.str());
-    }
-  }
-}
-
 /// @brief Apply a transform to a buffer
 bool Transform(const TransformFunctionArray& transformFunctions,
-               PixelArray buffer,
+               PixelBuffer *buffer,
                int width,
                int height,
                Pixel::Format pixelFormat )
@@ -318,7 +232,7 @@ struct PixelType
 };
 
 template<size_t N>
-void FlipVertical(PixelArray buffer, int width, int height)
+void FlipVertical(PixelBuffer* buffer, int width, int height)
 {
   // Destination pixel, set as the first pixel of screen
   auto to = reinterpret_cast<PixelType<N>*>( buffer );
@@ -334,7 +248,7 @@ void FlipVertical(PixelArray buffer, int width, int height)
 }
 
 template<size_t N>
-void FlipHorizontal(PixelArray buffer, int width, int height)
+void FlipHorizontal(PixelBuffer* buffer, int width, int height)
 {
   for(auto iy = 0; iy < height; ++iy)
   {
@@ -350,7 +264,7 @@ void FlipHorizontal(PixelArray buffer, int width, int height)
 }
 
 template<size_t N>
-void Transpose(PixelArray buffer, int width, int height)
+void Transpose(PixelBuffer* buffer, int width, int height)
 {
   //Transform vertically only
   for(auto iy = 0; iy < height / 2; ++iy)
@@ -365,7 +279,7 @@ void Transpose(PixelArray buffer, int width, int height)
 }
 
 template<size_t N>
-void Transverse(PixelArray buffer, int width, int height)
+void Transverse(PixelBuffer* buffer, int width, int height)
 {
   using PixelT = PixelType<N>;
   Vector<PixelT> data;
@@ -388,7 +302,7 @@ void Transverse(PixelArray buffer, int width, int height)
 
 
 template<size_t N>
-void Rotate90(PixelArray buffer, int width, int height)
+void Rotate90(PixelBuffer* buffer, int width, int height)
 {
   using PixelT = PixelType<N>;
   Vector<PixelT> data;
@@ -417,7 +331,7 @@ void Rotate90(PixelArray buffer, int width, int height)
 }
 
 template<size_t N>
-void Rotate180(PixelArray buffer, int width, int height)
+void Rotate180(PixelBuffer* buffer, int width, int height)
 {
   using PixelT = PixelType<N>;
   Vector<PixelT> data;
@@ -441,7 +355,7 @@ void Rotate180(PixelArray buffer, int width, int height)
 
 
 template<size_t N>
-void Rotate270(PixelArray buffer, int width, int height)
+void Rotate270(PixelBuffer* buffer, int width, int height)
 {
   using PixelT = PixelType<N>;
   Vector<PixelT> data;
@@ -528,7 +442,7 @@ bool LoadJpegHeader( FILE *fp, unsigned int &width, unsigned int &height )
   return true;
 }
 
-bool LoadBitmapFromJpeg( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+bool LoadBitmapFromJpeg( const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   const int flags= 0;
   FILE* const fp = input.file;
@@ -591,28 +505,12 @@ bool LoadBitmapFromJpeg( const ImageLoader::Input& input, Dali::Devel::PixelBuff
 
   auto transform = JpegTransform::NONE;
 
-  // extract exif data
-  auto exifData = MakeExifDataFromData(jpegBufferPtr, jpegBufferSize);
-
-  if( exifData && input.reorientationRequested )
-  {
-    transform = ConvertExifOrientation(exifData.get());
-  }
-
-  std::unique_ptr<Property::Map> exifMap;
-  exifMap.reset( new Property::Map() );
-
-  for( auto k = 0u; k < EXIF_IFD_COUNT; ++k )
+  if( input.reorientationRequested )
   {
-    auto content = exifData->ifd[k];
-    for (auto i = 0u; i < content->count; ++i)
+    auto exifData = MakeExifDataFromData(jpegBufferPtr, jpegBufferSize);
+    if( exifData )
     {
-      auto       &&tag      = content->entries[i];
-      const char *shortName = exif_tag_get_name_in_ifd(tag->tag, static_cast<ExifIfd>(k));
-      if(shortName)
-      {
-        AddExifFieldPropertyMap(*exifMap, *tag, static_cast<ExifIfd>(k));
-      }
+      transform = ConvertExifOrientation(exifData.get());
     }
   }
 
@@ -703,12 +601,7 @@ bool LoadBitmapFromJpeg( const ImageLoader::Input& input, Dali::Devel::PixelBuff
   }
 #endif
   // Allocate a bitmap and decompress the jpeg buffer into its pixel buffer:
-  bitmap = Dali::Devel::PixelBuffer::New(scaledPostXformWidth, scaledPostXformHeight, pixelFormat);
-
-  // set metadata
-  GetImplementation(bitmap).SetMetadata( std::move(exifMap) );
-
-  auto bitmapPixelBuffer = bitmap.GetBuffer();
+  PixelBuffer* bitmapPixelBuffer =  bitmap.GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, scaledPostXformWidth, scaledPostXformHeight ) ;
 
   if( tjDecompress2( jpeg.get(), jpegBufferPtr, jpegBufferSize, reinterpret_cast<unsigned char*>( bitmapPixelBuffer ), scaledPreXformWidth, 0, scaledPreXformHeight, pixelLibJpegType, flags ) == -1 )
   {
@@ -814,7 +707,6 @@ bool LoadBitmapFromJpeg( const ImageLoader::Input& input, Dali::Devel::PixelBuff
       break;
     }
   }
-
   return result;
 }
 
index bae32c6..baf69b0 100644 (file)
 
 namespace Dali
 {
-namespace Devel
+
+namespace Integration
 {
-class PixelBuffer;
+  class Bitmap;
 }
 
-
 namespace TizenPlatform
 {
 
@@ -50,7 +50,7 @@ const unsigned char MAGIC_BYTE_2 = 0xD8;
  * @param[out] bitmap The bitmap class where the decoded image will be stored
  * @return  true if file decoded successfully, false otherwise
  */
-bool LoadBitmapFromJpeg( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap );
+bool LoadBitmapFromJpeg( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * Loads the header of a JPEG file and fills in the width and height appropriately.
index fc67104..d39c361 100755 (executable)
 #include "loader-ktx.h"
 
 // EXTERNAL INCLUDES
+#include <cstdio>
+#include <cstdlib>
 #include <cstring>
+#include <stdint.h>
 #include <dali/public-api/common/compile-time-assert.h>
 #include <dali/integration-api/debug.h>
-#include <adaptors/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/integration-api/bitmap.h>
+#include <dali/public-api/images/pixel.h>
 
 namespace Dali
 {
+using Integration::Bitmap;
+using Dali::Integration::PixelBuffer;
 
 namespace TizenPlatform
 {
@@ -532,7 +538,7 @@ bool LoadKtxHeader( const ImageLoader::Input& input, unsigned int& width, unsign
 }
 
 // File loading API entry-point:
-bool LoadBitmapFromKtx( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+bool LoadBitmapFromKtx( const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   DALI_COMPILE_TIME_ASSERT( sizeof(Byte) == 1);
   DALI_COMPILE_TIME_ASSERT( sizeof(uint32_t) == 4);
@@ -586,9 +592,7 @@ bool LoadBitmapFromKtx( const ImageLoader::Input& input, Dali::Devel::PixelBuffe
   }
 
   // Load up the image bytes:
-  bitmap = Dali::Devel::PixelBuffer::New(width, height, pixelFormat);
-  auto pixels = bitmap.GetBuffer();
-
+  PixelBuffer* const pixels = bitmap.GetCompressedProfile()->ReserveBufferOfSize( pixelFormat, width, height, imageByteCount );
   if(!pixels)
   {
     DALI_LOG_ERROR( "Unable to reserve a pixel buffer to load the requested bitmap into.\n" );
index b7f01a8..c019ae8 100644 (file)
 
 namespace Dali
 {
-namespace Devel
+
+namespace Integration
 {
-class PixelBuffer;
+  class Bitmap;
 }
 
 namespace TizenPlatform
@@ -47,7 +48,7 @@ const unsigned char MAGIC_BYTE_2 = 0x4B;
  * @param[out] bitmap The bitmap class where the decoded image will be stored
  * @return  true if file loaded successfully, false otherwise
  */
-bool LoadBitmapFromKtx( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap );
+bool LoadBitmapFromKtx( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * Loads the header of a KTX file and fills in the width and height appropriately.
index 872e8ee..2b2309e 100755 (executable)
 #include "loader-png.h"
 
 #include <cstring>
+#include <cstdlib>
 
 #include <zlib.h>
 #include <png.h>
 
+#include <dali/integration-api/bitmap.h>
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/images/image.h>
+#include "dali/public-api/math/math-utils.h"
+#include "dali/public-api/math/vector2.h"
 #include "platform-capabilities.h"
-#include <adaptors/devel-api/adaptor-framework/pixel-buffer.h>
 
 namespace Dali
 {
+
+using Integration::Bitmap;
+using Dali::Integration::PixelBuffer;
+
 namespace TizenPlatform
 {
 
@@ -121,7 +128,7 @@ bool LoadPngHeader( const ImageLoader::Input& input, unsigned int& width, unsign
   return success;
 }
 
-bool LoadBitmapFromPng( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+bool LoadBitmapFromPng( const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   png_structp png = NULL;
   png_infop info = NULL;
@@ -130,6 +137,7 @@ bool LoadBitmapFromPng( const ImageLoader::Input& input, Dali::Devel::PixelBuffe
   /// @todo: consider parameters
   unsigned int y;
   unsigned int width, height;
+  unsigned char *pixels;
   png_bytep *rows;
   unsigned int bpp = 0; // bytes per pixel
   bool valid = false;
@@ -304,7 +312,7 @@ bool LoadBitmapFromPng( const ImageLoader::Input& input, Dali::Devel::PixelBuffe
   }
 
   // decode the whole image into bitmap buffer
-  auto pixels = (bitmap = Dali::Devel::PixelBuffer::New(bufferWidth, bufferHeight, pixelFormat)).GetBuffer();
+  pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer(pixelFormat, width, height, bufferWidth, bufferHeight);
 
   DALI_ASSERT_DEBUG(pixels);
   rows = reinterpret_cast< png_bytep* >( malloc(sizeof(png_bytep) * height) );
index 0c9c493..e676588 100644 (file)
 
 namespace Dali
 {
-namespace Devel
+
+namespace Integration
 {
-class PixelBuffer;
+  class Bitmap;
 }
 
 namespace TizenPlatform
@@ -49,7 +50,7 @@ const unsigned char MAGIC_BYTE_2 = 0x50;
  * @param[out] bitmap The bitmap class where the decoded image will be stored
  * @return  true if file decoded successfully, false otherwise
  */
-bool LoadBitmapFromPng( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap );
+bool LoadBitmapFromPng( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * Loads the header of a PNG file and fills in the width and height appropriately.
index 44560bb..4a176ef 100755 (executable)
 
 // INTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
-#include <adaptors/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/integration-api/bitmap.h>
+#include <dali/public-api/common/dali-vector.h>
 
 namespace Dali
 {
-
+using Integration::Bitmap;
+using Dali::Integration::PixelBuffer;
 namespace TizenPlatform
 {
 
@@ -90,7 +92,7 @@ int extractMultiByteInteger(unsigned int *data, void *map, size_t length, size_t
 
 }// end unnamed namespace
 
-bool LoadBitmapFromWbmp( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+bool LoadBitmapFromWbmp( const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   FILE* const fp = input.file;
   if(fp == NULL)
@@ -100,6 +102,7 @@ bool LoadBitmapFromWbmp( const ImageLoader::Input& input, Dali::Devel::PixelBuff
   }
   Dali::Vector<unsigned char> map;
   Dali::Vector<unsigned char> surface;//unsigned int
+  PixelBuffer* pixels = NULL;
   size_t position = 0;
 
   unsigned int w, h;
@@ -203,7 +206,7 @@ bool LoadBitmapFromWbmp( const ImageLoader::Input& input, Dali::Devel::PixelBuff
       cur++;
     }
   }
-  auto pixels = (bitmap = Dali::Devel::PixelBuffer::New(w, h, Pixel::L8)).GetBuffer();
+  pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer(Pixel::L8, w, h);//Pixel::RGBA8888
 
   memcpy( pixels, &surface[0], w * h ); //w * h * 4
 
index 619449f..a2040a0 100755 (executable)
@@ -24,9 +24,9 @@
 namespace Dali
 {
 
-namespace Devel
+namespace Integration
 {
-class PixelBuffer;
+  class Bitmap;
 }
 
 namespace TizenPlatform
@@ -39,7 +39,7 @@ class ResourceLoadingClient;
  * @param[out] bitmap The bitmap class where the decoded image will be stored
  * @return  true if file decoded successfully, false otherwise
  */
-bool LoadBitmapFromWbmp( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap );
+bool LoadBitmapFromWbmp( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * @param[in]  input  Information about the input image (including file pointer)
index 2bf6e6f..1a8a876 100644 (file)
@@ -28,7 +28,6 @@
 // INTERNAL INCLUDES
 #include "image-loaders/image-loader.h"
 #include "portable/file-reader.h"
-#include <adaptors/common/pixel-buffer-impl.h>
 
 namespace Dali
 {
@@ -70,8 +69,7 @@ Integration::ResourcePointer TizenPlatformAbstraction::LoadImageSynchronously(co
 
 Integration::BitmapPtr TizenPlatformAbstraction::DecodeBuffer( const Integration::BitmapResourceType& resource, uint8_t * buffer, size_t size )
 {
-  Integration::BitmapPtr resultBitmap;
-  Dali::Devel::PixelBuffer bitmap;
+  Integration::BitmapPtr bitmap = 0;
 
   Dali::Internal::Platform::FileReader fileReader( buffer, size );
   FILE * const fp = fileReader.GetFile();
@@ -83,29 +81,9 @@ Integration::BitmapPtr TizenPlatformAbstraction::DecodeBuffer( const Integration
       bitmap.Reset();
       DALI_LOG_WARNING( "Unable to decode bitmap supplied as in-memory blob.\n" );
     }
-    else
-    {
-      Integration::Bitmap::Profile profile{Integration::Bitmap::Profile::BITMAP_2D_PACKED_PIXELS};
-
-      // For backward compatibility the Bitmap must be created
-      auto retval = Integration::Bitmap::New(profile, Dali::ResourcePolicy::OWNED_DISCARD);
-
-      retval->GetPackedPixelsProfile()->ReserveBuffer(
-              bitmap.GetPixelFormat(),
-              bitmap.GetWidth(),
-              bitmap.GetHeight(),
-              bitmap.GetWidth(),
-              bitmap.GetHeight()
-            );
-
-      auto& impl = Dali::GetImplementation(bitmap);
-
-      std::copy( impl.GetBuffer(), impl.GetBuffer()+impl.GetBufferSize(), retval->GetBuffer());
-      resultBitmap.Reset(retval);
-    }
   }
 
-  return resultBitmap;
+  return bitmap;
 }
 
 bool TizenPlatformAbstraction::LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const