Revert "Revert "[4.0] Fixed BMP loader."" 86/165786/1
authordongsug.song <dongsug.song@samsung.com>
Thu, 4 Jan 2018 02:38:15 +0000 (11:38 +0900)
committerdongsug.song <dongsug.song@samsung.com>
Thu, 4 Jan 2018 02:38:24 +0000 (11:38 +0900)
This reverts commit 7293e3a2e2bbdf4c8904515e8d2d08d3afd23305.

Change-Id: I7b9598d7d3fc26464e6ce8e96412eb94f188a695

automated-tests/images/flag-24bpp.bmp [new file with mode: 0644]
automated-tests/images/flag-24bpp.buffer [new file with mode: 0644]
automated-tests/src/dali-adaptor-internal/CMakeLists.txt
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-BmpLoader.cpp [new file with mode: 0644]
platform-abstractions/tizen/image-loaders/loader-bmp.cpp

diff --git a/automated-tests/images/flag-24bpp.bmp b/automated-tests/images/flag-24bpp.bmp
new file mode 100644 (file)
index 0000000..bbc1518
Binary files /dev/null and b/automated-tests/images/flag-24bpp.bmp differ
diff --git a/automated-tests/images/flag-24bpp.buffer b/automated-tests/images/flag-24bpp.buffer
new file mode 100644 (file)
index 0000000..9af4726
Binary files /dev/null and b/automated-tests/images/flag-24bpp.buffer differ
index c953ca4..2f6845e 100644 (file)
@@ -11,6 +11,7 @@ SET(TC_SOURCES
     utc-Dali-FontClient.cpp
     utc-Dali-GifLoader.cpp
     utc-Dali-IcoLoader.cpp
+    utc-Dali-BmpLoader.cpp
     utc-Dali-ImageOperations.cpp
     utc-Dali-Internal-PixelBuffer.cpp
     utc-Dali-Lifecycle-Controller.cpp
index a5fd26e..c3f7abe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
@@ -39,8 +39,8 @@ ImageDetails::ImageDetails( const char * const _name, unsigned int _width, unsig
   height( _height ),
   reportedWidth( _width ),
   reportedHeight( _height ),
-  refBufferSize( _width * _height ),
-  refBuffer( new Dali::PixelBuffer[ refBufferSize ] )
+  refBufferSize( 0u ),
+  refBuffer( nullptr )
 {
   LoadBuffer();
 }
@@ -51,27 +51,33 @@ ImageDetails::ImageDetails( const char * const _name, unsigned int _width, unsig
   height( _height ),
   reportedWidth( _reportedWidth ),
   reportedHeight( _reportedHeight ),
-  refBufferSize( _width * _height ),
-  refBuffer( new Dali::PixelBuffer[ refBufferSize ] )
+  refBufferSize( 0u ),
+  refBuffer( nullptr )
 {
   LoadBuffer();
 }
 
 ImageDetails::~ImageDetails()
 {
-  delete [] refBuffer;
+  if( refBuffer )
+  {
+    delete[] refBuffer;
+  }
 }
 
 void ImageDetails::LoadBuffer()
 {
   // Load the reference buffer from the buffer file
-
   std::string refBufferFilename( name + ".buffer" );
   FILE *fp = fopen ( refBufferFilename.c_str(), "rb" );
   AutoCloseFile autoCloseBufferFile( fp );
 
   if ( fp )
   {
+    fseek( fp, 0, SEEK_END );
+    refBufferSize = ftell( fp );
+    fseek( fp, 0, SEEK_SET );
+    refBuffer = reinterpret_cast<Dali::PixelBuffer*>( malloc( refBufferSize ) );
     fread( refBuffer, sizeof( Dali::PixelBuffer ), refBufferSize, fp );
   }
 }
index 9a3ce7a..fa7fa0d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
@@ -66,7 +66,7 @@ struct ImageDetails
   unsigned int reportedWidth;
   unsigned int reportedHeight;
   unsigned int refBufferSize;
-  Dali::PixelBuffer* const refBuffer;
+  Dali::PixelBuffer* refBuffer;
 
 private:
 
diff --git a/automated-tests/src/dali-adaptor-internal/utc-Dali-BmpLoader.cpp b/automated-tests/src/dali-adaptor-internal/utc-Dali-BmpLoader.cpp
new file mode 100644 (file)
index 0000000..dd8838e
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
+
+#include <iostream>
+#include <stdlib.h>
+#include <dali-test-suite-utils.h>
+
+#include "platform-abstractions/tizen/image-loaders/loader-bmp.h"
+#include "image-loaders.h"
+
+using namespace Dali;
+
+namespace
+{
+
+static const LoadFunctions BmpLoaders( TizenPlatform::LoadBmpHeader, TizenPlatform::LoadBitmapFromBmp );
+
+} // Unnamed namespace.
+
+int UtcDaliBmp24bpp(void)
+{
+  ImageDetails image( TEST_IMAGE_DIR "/flag-24bpp.bmp", 32u, 32u );
+
+  TestImageLoading( image, BmpLoaders );
+
+  END_TEST;
+}
+
index 37f3c26..fdd0837 100644 (file)
@@ -1242,6 +1242,12 @@ bool LoadBitmapFromBmp( const ImageLoader::Input& input, Integration::Bitmap& bi
     {
       pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer(pixelFormat, infoHeader.width, infoHeader.height);
     }
+    else
+    {
+      pixelBufferW = infoHeader.width;
+      pixelBufferH = infoHeader.height;
+      newPixelFormat = pixelFormat;
+    }
     break;
   }