// the data in the file is bottom up, and we store the data top down
pixelsPtr = pixels + (((height - 1) - index) * rowStride);
}
- for(std::uint8_t j = 0; j < width; ++j)
+ for(std::uint32_t j = 0; j < width; ++j)
{
ctIndex = colorIndex[width * index + j];
pixelsPtr[3 * j] = colorTable[4 * ctIndex + 2];
switch(infoHeader.compression)
{
case 0:
+ {
switch(infoHeader.bitsPerPixel)
{
case 32:
- pixelFormat = Pixel::BGR8888;
+ {
+ pixelFormat = Pixel::RGBA8888;
break;
+ }
case 24:
+ {
if(fileHeader.offset == FileHeaderOffsetOfRGB24V5) //0x8A
{
customizedFormat = BMP_RGB24V5;
pixelFormat = Pixel::RGB888;
}
break;
+ }
case 16:
+ {
customizedFormat = BMP_RGB555;
break;
+ }
case 8:
+ {
customizedFormat = BMP_RGB8;
break;
+ }
case 4: // RGB4
+ {
customizedFormat = BMP_RGB4;
break;
+ }
case 1: //RGB1
+ {
customizedFormat = BMP_RGB1;
break;
+ }
+
default:
+ {
DALI_LOG_ERROR("%d bits per pixel not supported for BMP files\n", infoHeader.bitsPerPixel);
return false;
+ }
}
break;
+ }
case 1: //// RLE8
{
if(infoHeader.bitsPerPixel == 8)
break;
}
default:
+ {
DALI_LOG_ERROR("Compression not supported for BMP files\n");
return false;
+ }
}
bool topDown = false;
case BMP_BITFIELDS32V4:
{
pixelBufferH = abs(infoHeader.height);
- newPixelFormat = Pixel::RGB8888;
+ newPixelFormat = Pixel::RGBA8888;
break;
}
case BMP_RGB24V5:
break;
}
default:
+ {
if(pixelFormat == Pixel::RGB565)
{
pixelBufferW = ((imageW & 3) != 0) ? imageW + 4 - (imageW & 3) : imageW;
newPixelFormat = pixelFormat;
}
break;
+ }
}
bitmap = Dali::Devel::PixelBuffer::New(pixelBufferW, pixelBufferH, newPixelFormat);
break;
}
+ // If 32 bit mode then swap Blue and Red pixels. And Alpha pixels must be ignored.
+ // Reference : https://users.cs.fiu.edu/~czhang/teaching/cop4225/project_files/bitmap_format.htm
+ // ... if the compression field of the bitmap is set to bi_rgb, ... the high byte in each dword is not used.
+ // RGB8888 format doesn't seem to be supported by graphics-api
+ if(infoHeader.bitsPerPixel == 32)
+ {
+ for(uint32_t i = 0; i < rowStride; i += 4)
+ {
+ uint8_t temp = pixelsIterator[i];
+ pixelsIterator[i] = pixelsIterator[i + 2];
+ pixelsIterator[i + 2] = temp;
+ pixelsIterator[i + 3] = 255u;
+ }
+ }
+
// If 24 bit mode then swap Blue and Red pixels
// BGR888 doesn't seem to be supported by dali-core
if(infoHeader.bitsPerPixel == 24)
{
- for(unsigned int i = 0; i < rowStride; i += 3)
+ for(uint32_t i = 0; i < rowStride; i += 3)
{
- unsigned char temp = pixelsIterator[i];
+ uint8_t temp = pixelsIterator[i];
pixelsIterator[i] = pixelsIterator[i + 2];
pixelsIterator[i + 2] = temp;
}