From 74d3a9967f6cdd74b0a81e2b9b0a656c9f610f12 Mon Sep 17 00:00:00 2001 From: cutealien Date: Sat, 23 Sep 2023 17:08:43 +0000 Subject: [PATCH] TGA images with palettes in 24 or 32 bit now create 32 bit images Was creating 16-bit images for those before. Could also support 24-bit images, but either we need another convert function or another palette for that (the 16 and 32 bit both work with 32 bit palettes, the 24 bit conversion function only with 24 bit palettes) git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6533 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/CImageLoaderTGA.cpp | 30 +++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/source/Irrlicht/CImageLoaderTGA.cpp b/source/Irrlicht/CImageLoaderTGA.cpp index e581ba0d..ce36e23a 100644 --- a/source/Irrlicht/CImageLoaderTGA.cpp +++ b/source/Irrlicht/CImageLoaderTGA.cpp @@ -193,14 +193,28 @@ IImage* CImageLoaderTGA::loadImage(io::IReadFile* file) const } else { - image = new CImage(ECF_A1R5G5B5, - core::dimension2d(header.ImageWidth, header.ImageHeight)); - if (image) - CColorConverter::convert8BitTo16Bit((u8*)data, - (s16*)image->getData(), - header.ImageWidth,header.ImageHeight, - (s32*) palette, 0, - (header.ImageDescriptor&0x20)==0); + switch ( header.ColorMapEntrySize ) + { + case 16: + image = new CImage(ECF_A1R5G5B5, core::dimension2d(header.ImageWidth, header.ImageHeight)); + if ( image ) + CColorConverter::convert8BitTo16Bit((u8*)data, + (s16*)image->getData(), + header.ImageWidth,header.ImageHeight, + (s32*) palette, 0, + (header.ImageDescriptor&0x20)==0); + break; + // Note: 24 bit with palette would need a 24 bit palette, too lazy doing that now (textures will prefer 32-bit later anyway) + default: + image = new CImage(ECF_A8R8G8B8, core::dimension2d(header.ImageWidth, header.ImageHeight)); + if ( image ) + CColorConverter::convert8BitTo32Bit((u8*)data, + (u8*)image->getData(), + header.ImageWidth,header.ImageHeight, + (u8*) palette, 0, + (header.ImageDescriptor&0x20)==0); + break; + } } } break;