mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-08 16:53:52 +01:00
CImageLoaderBMP now supports loading 1-bit images with palette data
The feature everyone has been waiting for!!! Or not... Anyway it works now :-) git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6600 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
b17fe835bc
commit
8f8a4ef5e1
@ -1,6 +1,7 @@
|
||||
--------------------------
|
||||
Changes in 1.9 (not yet released)
|
||||
|
||||
- CImageLoaderBMP now supports loading 1-bit images with palette data
|
||||
- Hardware meshbuffers are now deleted when they hold the last reference to a meshbuffer
|
||||
- Variable order inside SMaterial and SMaterialLayer changed for better packing
|
||||
- line3d::getClosestPoint can now chose between using line or line segment
|
||||
|
@ -12,7 +12,7 @@ namespace video
|
||||
{
|
||||
|
||||
//! converts a monochrome bitmap to A1R5G5B5 data
|
||||
void CColorConverter::convert1BitTo16Bit(const u8* in, s16* out, u32 width, u32 height, u32 linepad, bool flip)
|
||||
void CColorConverter::convert1BitTo16Bit(const u8* in, s16* out, u32 width, u32 height, u32 linepad, bool flip, s16 col0, s16 col1)
|
||||
{
|
||||
if (!in || !out)
|
||||
return;
|
||||
@ -28,7 +28,7 @@ void CColorConverter::convert1BitTo16Bit(const u8* in, s16* out, u32 width, u32
|
||||
|
||||
for (u32 x=0; x<width; ++x)
|
||||
{
|
||||
out[x] = *in>>shift & 0x01 ? (s16)0xffff : (s16)0x8000;
|
||||
out[x] = *in>>shift & 0x01 ? col1 : col0;
|
||||
|
||||
if ((--shift)<0) // 8 pixel done
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ class CColorConverter
|
||||
public:
|
||||
|
||||
//! converts a monochrome bitmap to A1R5G5B5
|
||||
static void convert1BitTo16Bit(const u8* in, s16* out, u32 width, u32 height, u32 linepad=0, bool flip=false);
|
||||
static void convert1BitTo16Bit(const u8* in, s16* out, u32 width, u32 height, u32 linepad=0, bool flip=false, s16 col0=(s16)0x8000, s16 col1=(s16)0xffff);
|
||||
|
||||
//! converts a 4 bit palettized image to A1R5G5B5
|
||||
static void convert4BitTo16Bit(const u8* in, s16* out, u32 width, u32 height, const s32* palette, u32 linepad=0, bool flip=false);
|
||||
@ -32,7 +32,7 @@ public:
|
||||
//! converts a 8 bit palettized or non palettized image (A8) into A8R8G8B8
|
||||
static void convert8BitTo32Bit(const u8* in, u8* out, u32 width, u32 height, const u8* palette, u32 linepad = 0, bool flip=false);
|
||||
|
||||
//! converts R8G8B8 16 bit data to A1R5G5B5 data
|
||||
//! converts 16bit data to 16bit data (can flip and do endian conversion)
|
||||
static void convert16BitTo16Bit(const s16* in, s16* out, u32 width, u32 height, u32 linepad=0, bool flip=false);
|
||||
|
||||
//! copies R8G8B8 24 bit data to 24 data, and flips and
|
||||
|
@ -414,7 +414,20 @@ IImage* CImageLoaderBMP::loadImage(io::IReadFile* file) const
|
||||
case 1:
|
||||
image = new CImage(ECF_A1R5G5B5, dim);
|
||||
if (image)
|
||||
CColorConverter::convert1BitTo16Bit(bmpData, (s16*)image->getData(), header.Width, header.Height, pitch, true);
|
||||
{
|
||||
s16 colors[2] = {(s16)0x8000, (s16)0xffff }; // off: only alpha set, on: all white
|
||||
if ( paletteSize == 1 )
|
||||
{
|
||||
u8 in = 0;
|
||||
CColorConverter::convert8BitTo16Bit(&in, colors, 1, 1, paletteData);
|
||||
}
|
||||
else if ( paletteSize >= 2 )
|
||||
{
|
||||
u8 in[2] = { 0, 1 };
|
||||
CColorConverter::convert8BitTo16Bit(in, colors, 2, 1, paletteData);
|
||||
}
|
||||
CColorConverter::convert1BitTo16Bit(bmpData, (s16*)image->getData(), header.Width, header.Height, pitch, true, colors[0], colors[1]);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
image = new CImage(ECF_A1R5G5B5, dim);
|
||||
|
Loading…
Reference in New Issue
Block a user