Revert "Revert "Revert "[4.0] Fixed BMP loader."""
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-adaptor-internal / image-loaders.cpp
index c3f7abe..a5fd26e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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( 0u ),
-  refBuffer( nullptr )
+  refBufferSize( _width * _height ),
+  refBuffer( new Dali::PixelBuffer[ refBufferSize ] )
 {
   LoadBuffer();
 }
@@ -51,33 +51,27 @@ ImageDetails::ImageDetails( const char * const _name, unsigned int _width, unsig
   height( _height ),
   reportedWidth( _reportedWidth ),
   reportedHeight( _reportedHeight ),
-  refBufferSize( 0u ),
-  refBuffer( nullptr )
+  refBufferSize( _width * _height ),
+  refBuffer( new Dali::PixelBuffer[ refBufferSize ] )
 {
   LoadBuffer();
 }
 
 ImageDetails::~ImageDetails()
 {
-  if( refBuffer )
-  {
-    delete[] 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 );
   }
 }