X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=platform-abstractions%2Ftizen%2Fimage-loaders%2Floader-astc.cpp;h=a0362aa36f949c078170454ba3911475e2df0294;hb=f4b05fe51ddba1d7d2035103ef3cfcd1d4741d3c;hp=aed1071679ceff3374dee42d0245b208387bad6a;hpb=5c880af37b1320a427d12fbfdb81c0d99b15801e;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/platform-abstractions/tizen/image-loaders/loader-astc.cpp b/platform-abstractions/tizen/image-loaders/loader-astc.cpp index aed1071..a0362aa 100755 --- a/platform-abstractions/tizen/image-loaders/loader-astc.cpp +++ b/platform-abstractions/tizen/image-loaders/loader-astc.cpp @@ -19,23 +19,16 @@ #include "loader-astc.h" // EXTERNAL INCLUDES -#include -#include #include -#include #include #include -#include #include +#include namespace Dali { -using Integration::Bitmap; -using Dali::Integration::PixelBuffer; - namespace TizenPlatform { - namespace { @@ -122,11 +115,11 @@ Pixel::Format GetAstcPixelFormat( AstcFileHeader& header ) * @param[out] fileHeader This will be populated with the header data * @return True if the file is valid, false otherwise */ -bool LoadAstcHeader( FILE * const filePointer, unsigned int &width, unsigned int &height, AstcFileHeader &fileHeader ) +bool LoadAstcHeader( FILE * const filePointer, unsigned int& width, unsigned int& height, AstcFileHeader& fileHeader ) { // Pull the bytes of the file header in as a block: - unsigned int readLength = sizeof( AstcFileHeader ); - if( fread( (void*)&fileHeader, 1, readLength, filePointer ) != readLength ) + const unsigned int readLength = sizeof( AstcFileHeader ); + if( fread( &fileHeader, 1, readLength, filePointer ) != readLength ) { return false; } @@ -174,7 +167,7 @@ bool LoadAstcHeader( const ImageLoader::Input& input, unsigned int& width, unsig } // File loading API entry-point: -bool LoadBitmapFromAstc( const ImageLoader::Input& input, Integration::Bitmap& bitmap ) +bool LoadBitmapFromAstc( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap ) { FILE* const filePointer = input.file; if( !filePointer ) @@ -231,16 +224,13 @@ bool LoadBitmapFromAstc( const ImageLoader::Input& input, Integration::Bitmap& b return false; } - // 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; - } + // allocate pixel data + bitmap = Dali::Devel::PixelBuffer::New(width, height, pixelFormat); + auto pixels = bitmap.GetBuffer(); // 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 ) {