#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
{
width = infoHeader.width;
height = abs(infoHeader.height);
+ if( infoHeader.width == 0 )
+ {
+ return false;
+ }
+
return true;
}
* @return true, if decode successful, false otherwise
*/
bool DecodeRGB24V5(FILE *fp,
- PixelBuffer *pixels,
+ unsigned char* pixels,
unsigned int width,
unsigned int height,
unsigned int offset,
for(unsigned int yPos = 0; yPos < height; yPos ++)
{
- PixelBuffer *pixelsPtr = NULL;
+ unsigned char* pixelsPtr = NULL;
if(topDown)
{
pixelsPtr = pixels + ( yPos * rowStride);
* @return true, if decode successful, false otherwise
*/
bool DecodeBF32V4(FILE *fp,
- PixelBuffer *pixels,
+ unsigned char* pixels,
unsigned int width,
unsigned int height,
unsigned int offset,
for(unsigned int yPos = 0; yPos < height; yPos ++)
{
- PixelBuffer *pixelsPtr = NULL;
+ unsigned char* pixelsPtr = NULL;
if(topDown)
{
pixelsPtr = pixels + ( yPos * rowStride);
* @return true, if decode successful, false otherwise
*/
bool DecodeBF32(FILE *fp,
- PixelBuffer *pixels,
+ unsigned char* pixels,
unsigned int width,
unsigned int height,
unsigned int offset,
for (unsigned int yPos = 0; yPos < height; yPos++)
{
- PixelBuffer *pixelsPtr;
+ unsigned char* pixelsPtr;
if (topDown)
{
// the data in the file is top down, and we store the data top down
* @return true, if decode successful, false otherwise
*/
bool DecodeBF565(FILE *fp,
- PixelBuffer *pixels,
+ unsigned char* pixels,
unsigned int width,
unsigned int height,
unsigned int offset,
for(unsigned int i = 0; i < height; i++)
{
- PixelBuffer *pixelsPtr = NULL;
+ unsigned char* pixelsPtr = NULL;
if (topDown)
{
// the data in the file is top down, and we store the data top down
* @return true, if decode successful, false otherwise
*/
bool DecodeBF555(FILE *fp,
- PixelBuffer *pixels,
+ unsigned char* pixels,
unsigned int width,
unsigned int height,
unsigned int offset,
for (unsigned int yPos = 0; yPos < height; yPos++)
{
- PixelBuffer *pixelsPtr = NULL;
+ unsigned char* pixelsPtr = NULL;
if (topDown)
{
// the data in the file is top down, and we store the data top down
* @return true, if decode successful, false otherwise
*/
bool DecodeRGB555(FILE *fp,
- PixelBuffer *pixels,
+ unsigned char* pixels,
unsigned int width,
unsigned int height,
unsigned int offset,
}
for(unsigned int i = 0; i < height; i++)
{
- PixelBuffer *pixelsPtr = NULL;
+ unsigned char* pixelsPtr = NULL;
if (topDown)
{
// the data in the file is top down, and we store the data top down
* @return true, if decode successful, false otherwise
*/
bool DecodeRGB1(FILE *fp,
- PixelBuffer *pixels,
+ unsigned char* pixels,
unsigned int width,
unsigned int height,
unsigned int offset,
for(unsigned int index = 0; index < height; index = index + 1)
{
- PixelBuffer *pixelsPtr = NULL;
+ unsigned char* pixelsPtr = NULL;
if (topDown)
{
// the data in the file is top down, and we store the data top down
* @return true, if decode successful, false otherwise
*/
bool DecodeRGB4(FILE *fp,
- PixelBuffer *pixels,
+ unsigned char* pixels,
unsigned int width,
unsigned int height,
unsigned int offset,
for(unsigned int index = 0; index < height; index = index + 1)
{
- PixelBuffer *pixelsPtr = NULL;
+ unsigned char* pixelsPtr = NULL;
if (topDown)
{
// the data in the file is top down, and we store the data top down
* @return true, if decode successful, false otherwise
*/
bool DecodeRGB8(FILE *fp,
- PixelBuffer *pixels,
+ unsigned char* pixels,
unsigned int width,
unsigned int height,
unsigned int offset,
unsigned int ctIndex = 0;
for(unsigned int index = 0; index < height; index = index + 1)
{
- PixelBuffer *pixelsPtr = NULL;
+ unsigned char* pixelsPtr = NULL;
if (topDown)
{
// the data in the file is top down, and we store the data top down
* @return true, if decode successful, false otherwise
*/
bool DecodeRLE4(FILE *fp,
- PixelBuffer *pixels,
+ unsigned char* pixels,
unsigned int width,
unsigned int height,
unsigned int offset,
DALI_LOG_ERROR("Error decoding BMP_RLE4 format\n");
return false;
}
- PixelBuffer *pixelsPtr = pixels;
+ unsigned char* pixelsPtr = pixels;
width = ((width & 3) != 0) ? width + 4 - (width & 3) : width;
char cmd[2];
unsigned int cmdStride = 2;
* @return true, if decode successful, false otherwise
*/
bool DecodeRLE8(FILE *fp,
- PixelBuffer *pixels,
+ unsigned char* pixels,
unsigned int width,
unsigned int height,
unsigned int offset,
DALI_LOG_ERROR("Error decoding BMP_RLE8 format\n");
return false;
}
- PixelBuffer *pixelsPtr = pixels;
+ unsigned char* pixelsPtr = pixels;
unsigned int x = 0;
unsigned int y = 0;
unsigned int cmdStride = 2;
return ret;
}
-bool LoadBitmapFromBmp( const ImageLoader::Input& input, Integration::Bitmap& bitmap )
+bool LoadBitmapFromBmp( const ImageLoader::Input& input, Dali::Devel::PixelBuffer& 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)
{
padding = 4 - padding;
}
- PixelBuffer *pixels = NULL;
int imageW = infoHeader.width;
- int pixelBufferW = 0;
+ int pixelBufferW = infoHeader.width;
+ int pixelBufferH = infoHeader.height;
+ auto newPixelFormat = Pixel::Format::INVALID;
+
switch(customizedFormat)
{
case BMP_RLE8:
case BMP_BITFIELDS555:
{
pixelBufferW = ((imageW & 3) != 0) ? imageW + 4 - (imageW & 3) : imageW;
- pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGB888, pixelBufferW, abs(infoHeader.height));
+ pixelBufferH = abs(infoHeader.height);
+ newPixelFormat = Pixel::RGB888;
break;
}
case BMP_RGB1:
{
pixelBufferW = ((imageW & 63) != 0) ? imageW + 64 - (imageW & 63) : imageW;
- pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGB888, pixelBufferW, abs(infoHeader.height));
+ pixelBufferH = abs(infoHeader.height);
+ newPixelFormat = Pixel::RGB888;
break;
}
case BMP_BITFIELDS32:
case BMP_BITFIELDS32V4:
{
- pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGB8888, infoHeader.width, abs(infoHeader.height));
+ pixelBufferH = abs(infoHeader.height);
+ newPixelFormat = Pixel::RGB8888;
break;
}
case BMP_RGB24V5:
{
- pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGB888, infoHeader.width, infoHeader.height);
+ newPixelFormat = Pixel::RGB888;
break;
}
default:
if(pixelFormat == Pixel::RGB565 )
{
pixelBufferW = ((imageW & 3) != 0) ? imageW + 4 - (imageW & 3) : imageW;
- pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGB565, pixelBufferW, abs(infoHeader.height));
- }
- else
- {
- pixels = bitmap.GetPackedPixelsProfile()->ReserveBuffer(pixelFormat, infoHeader.width, infoHeader.height);
+ pixelBufferH = abs(infoHeader.height);
+ newPixelFormat = Pixel::RGB565;
}
break;
}
- // TODO: Add scaling support
+ bitmap = Dali::Devel::PixelBuffer::New(pixelBufferW, pixelBufferH, newPixelFormat);
+ auto pixels = bitmap.GetBuffer();
// Read the raw bitmap data
- PixelBuffer *pixelsPtr;
+ decltype(pixels) pixelsIterator = nullptr;
+
bool decodeResult(false);
switch(customizedFormat)
{
}
case BMP_RGB4:
{
- decodeResult = DecodeRGB4(fp, pixels, infoHeader.width, infoHeader.height, 14 + infoHeader.infoHeaderSize, topDown);
+ decodeResult = DecodeRGB4(fp, pixels, infoHeader.width, abs(infoHeader.height), 14 + infoHeader.infoHeaderSize, topDown);
break;
}
case BMP_RLE4:
if (topDown)
{
// the data in the file is top down, and we store the data top down
- pixelsPtr = pixels + ( yPos * rowStride);
+ pixelsIterator = pixels + ( yPos * rowStride);
}
else
{
// the data in the file is bottom up, and we store the data top down
- pixelsPtr = pixels + (((height-1)-yPos) * rowStride);
+ pixelsIterator = pixels + (((height-1)-yPos) * rowStride);
}
- if (fread(pixelsPtr, 1, rowStride, fp) != rowStride)
+ if (fread(pixelsIterator, 1, rowStride, fp) != rowStride)
{
DALI_LOG_ERROR("Error reading the BMP image\n");
break;
{
for(unsigned int i = 0; i < rowStride; i += 3)
{
- unsigned char temp = pixelsPtr[i];
- pixelsPtr[i] = pixelsPtr[i+2];
- pixelsPtr[i+2] = temp;
+ unsigned char temp = pixelsIterator[i];
+ pixelsIterator[i] = pixelsIterator[i+2];
+ pixelsIterator[i+2] = temp;
}
}