Commit 063c00cd authored by hybrid's avatar hybrid

Some more PCX formats supported. Not all modes are fully working, but I doubt...

Some more PCX formats supported. Not all modes are fully working, but I doubt anyone really uses them...

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1773 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 44846b6f
...@@ -72,7 +72,7 @@ IImage* CImageLoaderPCX::loadImage(io::IReadFile* file) const ...@@ -72,7 +72,7 @@ IImage* CImageLoaderPCX::loadImage(io::IReadFile* file) const
return 0; return 0;
// return if this isn't a supported type // return if this isn't a supported type
if (header.BitsPerPixel != 8) if ((header.BitsPerPixel != 8) && (header.BitsPerPixel != 4) && (header.BitsPerPixel != 1))
{ {
os::Printer::log("Unsupported bits per pixel in PCX file.", os::Printer::log("Unsupported bits per pixel in PCX file.",
file->getFileName(), irr::ELL_WARNING); file->getFileName(), irr::ELL_WARNING);
...@@ -119,7 +119,7 @@ IImage* CImageLoaderPCX::loadImage(io::IReadFile* file) const ...@@ -119,7 +119,7 @@ IImage* CImageLoaderPCX::loadImage(io::IReadFile* file) const
// read image data // read image data
const s32 width = header.XMax - header.XMin + 1; const s32 width = header.XMax - header.XMin + 1;
const s32 height = header.YMax - header.YMin + 1; const s32 height = header.YMax - header.YMin + 1;
const s32 imagebytes = header.BytesPerLine * header.Planes * header.BitsPerPixel / 8 * height; const s32 imagebytes = header.BytesPerLine * header.Planes * header.BitsPerPixel * height / 8;
u8* PCXData = new u8[imagebytes]; u8* PCXData = new u8[imagebytes];
u8 cnt, value; u8 cnt, value;
...@@ -164,19 +164,46 @@ IImage* CImageLoaderPCX::loadImage(io::IReadFile* file) const ...@@ -164,19 +164,46 @@ IImage* CImageLoaderPCX::loadImage(io::IReadFile* file) const
if (pad < 0) if (pad < 0)
pad = -pad; pad = -pad;
switch(header.Planes) // TODO: Other formats if (header.BitsPerPixel==8)
{ {
case 1: switch(header.Planes) // TODO: Other formats
image = new CImage(ECF_A1R5G5B5, core::dimension2d<s32>(width, height)); {
if (image) case 1:
CColorConverter::convert8BitTo16Bit(PCXData, (s16*)image->lock(), width, height, paletteData, pad); image = new CImage(ECF_A1R5G5B5, core::dimension2d<s32>(width, height));
break; if (image)
case 3: CColorConverter::convert8BitTo16Bit(PCXData, (s16*)image->lock(), width, height, paletteData, pad);
image = new CImage(ECF_R8G8B8, core::dimension2d<s32>(width, height)); break;
if (image) case 3:
CColorConverter::convert24BitTo24Bit(PCXData, (u8*)image->lock(), width, height, pad); image = new CImage(ECF_R8G8B8, core::dimension2d<s32>(width, height));
break; if (image)
}; CColorConverter::convert24BitTo24Bit(PCXData, (u8*)image->lock(), width, height, pad);
break;
}
}
else if (header.BitsPerPixel==4)
{
if (header.Planes==1)
{
image = new CImage(ECF_A1R5G5B5, core::dimension2d<s32>(width, height));
if (image)
CColorConverter::convert4BitTo16Bit(PCXData, (s16*)image->lock(), width, height, paletteData, pad);
}
}
else if (header.BitsPerPixel==1)
{
if (header.Planes==4)
{
image = new CImage(ECF_A1R5G5B5, core::dimension2d<s32>(width, height));
if (image)
CColorConverter::convert4BitTo16Bit(PCXData, (s16*)image->lock(), width, height, paletteData, pad);
}
else if (header.Planes==1)
{
image = new CImage(ECF_A1R5G5B5, core::dimension2d<s32>(width, height));
if (image)
CColorConverter::convert1BitTo16Bit(PCXData, (s16*)image->lock(), width, height, pad);
}
}
if (image) if (image)
image->unlock(); image->unlock();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment