#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
#include <dali/integration-api/debug.h>
+#include <dali/internal/system/common/file-closer.h>
+
+using namespace Dali::Internal::Platform;
+
namespace Dali
{
const unsigned int readLength = sizeof(T);
// Load the information directly into our structure
- if ( fread( &header, 1, readLength, fp ) != readLength )
+ if ( InternalFile::fread( &header, 1, readLength, fp ) != readLength )
{
return false;
}
DALI_LOG_ERROR("Error decoding BMP_RGB24V5 format\n");
return false;
}
- if ( fseek(fp, offset, SEEK_SET) )
+ if ( InternalFile::fseek(fp, offset, SEEK_SET) )
{
DALI_LOG_ERROR("Error seeking BMP_RGB24V5 data\n");
return false;
{
pixelsPtr = pixels + (((height-1)-yPos) * rowStride);
}
- if (fread(pixelsPtr, 1, rowStride, fp) != rowStride)
+ if (InternalFile::fread(pixelsPtr, 1, rowStride, fp) != rowStride)
{
DALI_LOG_ERROR("Error reading the BMP image\n");
return false;
if (padding)
{
// move past the padding.
- if( fseek(fp, padding, SEEK_CUR) )
+ if( InternalFile::fseek(fp, padding, SEEK_CUR) )
{
DALI_LOG_ERROR("Error moving past BMP_RGB24V5 padding\n");
}
DALI_LOG_ERROR("Error decoding BMP_BITFIELDS32V4 format\n");
return false;
}
- if( fseek(fp, offset, SEEK_SET) )
+ if( InternalFile::fseek(fp, offset, SEEK_SET) )
{
DALI_LOG_ERROR("Error seeking BMP_BITFIELDS32V4 data\n");
return false;
{
pixelsPtr = pixels + (((height-1)-yPos) * rowStride);
}
- if (fread(pixelsPtr, 1, rowStride, fp) != rowStride)
+ if (InternalFile::fread(pixelsPtr, 1, rowStride, fp) != rowStride)
{
DALI_LOG_ERROR("Error reading the BMP image\n");
return false;
if (padding)
{
// move past the padding.
- if( fseek(fp, padding, SEEK_CUR) )
+ if( InternalFile::fseek(fp, padding, SEEK_CUR) )
{
DALI_LOG_ERROR("Error moving past BMP_BITFIELDS32V4 padding\n");
}
DALI_LOG_ERROR("Error decoding BMP_BITFIELDS32 format\n");
return false;
}
- if( fseek(fp, offset, SEEK_SET) )
+ if( InternalFile::fseek(fp, offset, SEEK_SET) )
{
DALI_LOG_ERROR("Error seeking BMP_BITFIELDS32 data\n");
return false;
pixelsPtr = pixels + (((height-1)-yPos) * rowStride);
}
- if (fread(pixelsPtr, 1, rowStride, fp) != rowStride)
+ if (InternalFile::fread(pixelsPtr, 1, rowStride, fp) != rowStride)
{
DALI_LOG_ERROR("Error reading the BMP image\n");
return false;
if (padding)
{
// move past the padding.
- if( fseek(fp, padding, SEEK_CUR) )
+ if( InternalFile::fseek(fp, padding, SEEK_CUR) )
{
DALI_LOG_ERROR("Error moving past BMP_BITFIELDS32 padding\n");
}
DALI_LOG_ERROR("Error decoding RGB565 format\n");
return false;
}
- if( fseek(fp, offset, SEEK_SET) )
+ if( InternalFile::fseek(fp, offset, SEEK_SET) )
{
DALI_LOG_ERROR("Error seeking RGB565 data\n");
return false;
// the data in the file is bottom up, and we store the data top down
pixelsPtr = pixels + (((height - 1) - i) * rowStride);
}
- if(fread(pixelsPtr, 1, rowStride, fp) != rowStride)
+ if(InternalFile::fread(pixelsPtr, 1, rowStride, fp) != rowStride)
{
return false;
}
return false;
}
- if( fseek(fp, offset, SEEK_SET) )
+ if( InternalFile::fseek(fp, offset, SEEK_SET) )
{
DALI_LOG_ERROR("Error seeking BMP_BITFIELDS555 data\n");
return false;
for(unsigned int j = 0; j < height; j ++)
{
rawPtr = &raw[0] + ( j * rawStride);
- if(fread(rawPtr, 1, rawStride, fp) != rawStride)
+ if(InternalFile::fread(rawPtr, 1, rawStride, fp) != rawStride)
{
return false;
}
DALI_LOG_ERROR("Error decoding BMP_RGB555 format\n");
return false;
}
- if( fseek(fp, offset, SEEK_SET) )
+ if( InternalFile::fseek(fp, offset, SEEK_SET) )
{
DALI_LOG_ERROR("Error seeking BMP_RGB555 data\n");
return false;
for(unsigned int j = 0; j < height; j ++)
{
rawPtr = &raw[0] + ( j * rawStride);
- if(fread(rawPtr, 1, rawStride, fp) != rawStride)
+ if(InternalFile::fread(rawPtr, 1, rawStride, fp) != rawStride)
{
return false;
}
DALI_LOG_ERROR("Error decoding BMP_RGB1 format\n");
return false;
}
- if( fseek(fp, offset, SEEK_SET) )
+ if( InternalFile::fseek(fp, offset, SEEK_SET) )
{
DALI_LOG_ERROR("Error seeking BMP_RGB1 data\n");
return false;
unsigned int rowStride = fillw * 3; // RGB
- if(fread(colorTable, 1, 8, fp) != 8)
+ if(InternalFile::fread(colorTable, 1, 8, fp) != 8)
{
return false;
}
for(unsigned int i = 0; i < fillw * height; i += 8)
{
- if(fread(&cmd, 1, 1, fp) != 1)
+ if(InternalFile::fread(&cmd, 1, 1, fp) != 1)
{
return false;
}
DALI_LOG_ERROR("Error decoding BMP_RGB4 format\n");
return false;
}
- if( fseek(fp, offset, SEEK_SET) )
+ if( InternalFile::fseek(fp, offset, SEEK_SET) )
{
DALI_LOG_ERROR("Error seeking BMP_RGB4 data\n");
return false;
std::vector<char> colorIndex(fillw * height);
unsigned int rowStride = fillw * 3;
- if(fread(colorTable, 1, 64, fp) != 64)
+ if(InternalFile::fread(colorTable, 1, 64, fp) != 64)
{
return false;
}
for(unsigned int i = 0; i < fillw * height; i += 2)
{
- if (fread(&cmd, 1, 1, fp) != 1)
+ if (InternalFile::fread(&cmd, 1, 1, fp) != 1)
{
return false;
}
DALI_LOG_ERROR("Error decoding BMP_RGB8 format\n");
return false;
}
- if( fseek(fp, offset, SEEK_SET) )
+ if( InternalFile::fseek(fp, offset, SEEK_SET) )
{
DALI_LOG_ERROR("Error seeking BMP_RGB8 data\n");
return false;
std::vector<char> colorIndex(width * height);
unsigned int rowStride = width * 3;//RGB8->RGB24
- if(fread(&colorTable[0], 1, 1024, fp) != 1024)
+ if(InternalFile::fread(&colorTable[0], 1, 1024, fp) != 1024)
{
return false;
}
for(unsigned int i = 0; i < width * height; i ++)
{
- if (fread(&cmd, 1, 1, fp) != 1)
+ if (InternalFile::fread(&cmd, 1, 1, fp) != 1)
{
return false;
}
bool finish = false;
- if( fseek(fp, offset, SEEK_SET) )
+ if( InternalFile::fseek(fp, offset, SEEK_SET) )
{
DALI_LOG_ERROR("Error seeking BMP_RLE4 data\n");
return false;
}
- if (fread(colorTable, 1, 64, fp) != 64)
+ if (InternalFile::fread(colorTable, 1, 64, fp) != 64)
{
return false;
}
{
break;
}
- if (fread(cmd, 1, cmdStride, fp) != cmdStride)
+ if (InternalFile::fread(cmd, 1, cmdStride, fp) != cmdStride)
{
return false;
}
y ++;
break;
case 2: // delta
- if (fread(cmd, 1, cmdStride, fp) != cmdStride)
+ if (InternalFile::fread(cmd, 1, cmdStride, fp) != cmdStride)
{
DALI_LOG_ERROR("Error reading the BMP image\n");
return false;
bytesize >>= 1;
bytesize += (bytesize & 1);
run.resize(bytesize);
- if(fread(&run[0], 1, bytesize, fp) != bytesize)
+ if(InternalFile::fread(&run[0], 1, bytesize, fp) != bytesize)
{
DALI_LOG_ERROR("Error reading the BMP image\n");
return false;
char cmd[2];
std::vector<char> colorIndex(width * height);
- if( fseek(fp, offset, SEEK_SET) )
+ if( InternalFile::fseek(fp, offset, SEEK_SET) )
{
DALI_LOG_ERROR("Error seeking BMP_RLE8 data\n");
return false;
}
- if (fread(&colorTable[0], 1, 1024, fp) != 1024)
+ if (InternalFile::fread(&colorTable[0], 1, 1024, fp) != 1024)
{
return false;
}
{
break;
}
- if (fread(cmd, 1, cmdStride, fp) != cmdStride)
+ if (InternalFile::fread(cmd, 1, cmdStride, fp) != cmdStride)
{
return false;
}
y ++;
break;
case 2: // delta
- if (fread(cmd, 1, cmdStride, fp) != cmdStride)
+ if (InternalFile::fread(cmd, 1, cmdStride, fp) != cmdStride)
{
DALI_LOG_ERROR("Error reading the BMP image\n");
return false;
//absolute mode must be word-aligned
length += (length & 1);
run.resize(length);
- if(fread(&run[0], 1, length, fp) != length)
+ if(InternalFile::fread(&run[0], 1, length, fp) != length)
{
DALI_LOG_ERROR("Error reading the BMP image\n");
return false;
{
if(infoHeader.bitsPerPixel == 16)
{
- if( fseek(fp, 14 + infoHeader.infoHeaderSize + 1, SEEK_SET) )
+ if( InternalFile::fseek(fp, 14 + infoHeader.infoHeaderSize + 1, SEEK_SET) )
{
return false;
}
char mask;
- if(fread(&mask, 1, 1, fp) != 1)
+ if(InternalFile::fread(&mask, 1, 1, fp) != 1)
{
return false;
}
pixelsIterator = pixels + (((height-1)-yPos) * rowStride);
}
- if (fread(pixelsIterator, 1, rowStride, fp) != rowStride)
+ if (InternalFile::fread(pixelsIterator, 1, rowStride, fp) != rowStride)
{
DALI_LOG_ERROR("Error reading the BMP image\n");
break;
if (padding)
{
- if( fseek(fp, padding, SEEK_CUR) ) // move past the padding.
+ if( InternalFile::fseek(fp, padding, SEEK_CUR) ) // move past the padding.
{
DALI_LOG_ERROR("Error moving past BMP padding\n");
}