aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CImageLoaderWAL.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CImageLoaderWAL.cpp')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CImageLoaderWAL.cpp570
1 files changed, 285 insertions, 285 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CImageLoaderWAL.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CImageLoaderWAL.cpp
index f5d2f17..63a5e40 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CImageLoaderWAL.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CImageLoaderWAL.cpp
@@ -1,285 +1,285 @@
1// Copyright (C) 2004 Murphy McCauley 1// Copyright (C) 2004 Murphy McCauley
2// Copyright (C) 2007-2012 Christian Stehno 2// Copyright (C) 2007-2012 Christian Stehno
3// This file is part of the "Irrlicht Engine". 3// This file is part of the "Irrlicht Engine".
4// For conditions of distribution and use, see copyright notice in irrlicht.h 4// For conditions of distribution and use, see copyright notice in irrlicht.h
5 5
6#include "CImageLoaderWAL.h" 6#include "CImageLoaderWAL.h"
7 7
8#include "CColorConverter.h" 8#include "CColorConverter.h"
9#include "CImage.h" 9#include "CImage.h"
10#include "os.h" 10#include "os.h"
11#include "dimension2d.h" 11#include "dimension2d.h"
12#include "IVideoDriver.h" 12#include "IVideoDriver.h"
13#include "IFileSystem.h" 13#include "IFileSystem.h"
14#include "IReadFile.h" 14#include "IReadFile.h"
15#include "irrString.h" 15#include "irrString.h"
16 16
17namespace irr 17namespace irr
18{ 18{
19namespace video 19namespace video
20{ 20{
21 21
22#ifdef _IRR_COMPILE_WITH_LMP_LOADER_ 22#ifdef _IRR_COMPILE_WITH_LMP_LOADER_
23 23
24// Palette quake2 colormap.h, 768 byte, last is transparent 24// Palette quake2 colormap.h, 768 byte, last is transparent
25static const u32 colormap_h[256] = { 25static const u32 colormap_h[256] = {
26 0xFF000000,0xFF0F0F0F,0xFF1F1F1F,0xFF2F2F2F,0xFF3F3F3F,0xFF4B4B4B,0xFF5B5B5B,0xFF6B6B6B, 26 0xFF000000,0xFF0F0F0F,0xFF1F1F1F,0xFF2F2F2F,0xFF3F3F3F,0xFF4B4B4B,0xFF5B5B5B,0xFF6B6B6B,
27 0xFF7B7B7B,0xFF8B8B8B,0xFF9B9B9B,0xFFABABAB,0xFFBBBBBB,0xFFCBCBCB,0xFFDBDBDB,0xFFEBEBEB, 27 0xFF7B7B7B,0xFF8B8B8B,0xFF9B9B9B,0xFFABABAB,0xFFBBBBBB,0xFFCBCBCB,0xFFDBDBDB,0xFFEBEBEB,
28 0xFF0F0B07,0xFF170F0B,0xFF1F170B,0xFF271B0F,0xFF2F2313,0xFF372B17,0xFF3F2F17,0xFF4B371B, 28 0xFF0F0B07,0xFF170F0B,0xFF1F170B,0xFF271B0F,0xFF2F2313,0xFF372B17,0xFF3F2F17,0xFF4B371B,
29 0xFF533B1B,0xFF5B431F,0xFF634B1F,0xFF6B531F,0xFF73571F,0xFF7B5F23,0xFF836723,0xFF8F6F23, 29 0xFF533B1B,0xFF5B431F,0xFF634B1F,0xFF6B531F,0xFF73571F,0xFF7B5F23,0xFF836723,0xFF8F6F23,
30 0xFF0B0B0F,0xFF13131B,0xFF1B1B27,0xFF272733,0xFF2F2F3F,0xFF37374B,0xFF3F3F57,0xFF474767, 30 0xFF0B0B0F,0xFF13131B,0xFF1B1B27,0xFF272733,0xFF2F2F3F,0xFF37374B,0xFF3F3F57,0xFF474767,
31 0xFF4F4F73,0xFF5B5B7F,0xFF63638B,0xFF6B6B97,0xFF7373A3,0xFF7B7BAF,0xFF8383BB,0xFF8B8BCB, 31 0xFF4F4F73,0xFF5B5B7F,0xFF63638B,0xFF6B6B97,0xFF7373A3,0xFF7B7BAF,0xFF8383BB,0xFF8B8BCB,
32 0xFF000000,0xFF070700,0xFF0B0B00,0xFF131300,0xFF1B1B00,0xFF232300,0xFF2B2B07,0xFF2F2F07, 32 0xFF000000,0xFF070700,0xFF0B0B00,0xFF131300,0xFF1B1B00,0xFF232300,0xFF2B2B07,0xFF2F2F07,
33 0xFF373707,0xFF3F3F07,0xFF474707,0xFF4B4B0B,0xFF53530B,0xFF5B5B0B,0xFF63630B,0xFF6B6B0F, 33 0xFF373707,0xFF3F3F07,0xFF474707,0xFF4B4B0B,0xFF53530B,0xFF5B5B0B,0xFF63630B,0xFF6B6B0F,
34 0xFF070000,0xFF0F0000,0xFF170000,0xFF1F0000,0xFF270000,0xFF2F0000,0xFF370000,0xFF3F0000, 34 0xFF070000,0xFF0F0000,0xFF170000,0xFF1F0000,0xFF270000,0xFF2F0000,0xFF370000,0xFF3F0000,
35 0xFF470000,0xFF4F0000,0xFF570000,0xFF5F0000,0xFF670000,0xFF6F0000,0xFF770000,0xFF7F0000, 35 0xFF470000,0xFF4F0000,0xFF570000,0xFF5F0000,0xFF670000,0xFF6F0000,0xFF770000,0xFF7F0000,
36 0xFF131300,0xFF1B1B00,0xFF232300,0xFF2F2B00,0xFF372F00,0xFF433700,0xFF4B3B07,0xFF574307, 36 0xFF131300,0xFF1B1B00,0xFF232300,0xFF2F2B00,0xFF372F00,0xFF433700,0xFF4B3B07,0xFF574307,
37 0xFF5F4707,0xFF6B4B0B,0xFF77530F,0xFF835713,0xFF8B5B13,0xFF975F1B,0xFFA3631F,0xFFAF6723, 37 0xFF5F4707,0xFF6B4B0B,0xFF77530F,0xFF835713,0xFF8B5B13,0xFF975F1B,0xFFA3631F,0xFFAF6723,
38 0xFF231307,0xFF2F170B,0xFF3B1F0F,0xFF4B2313,0xFF572B17,0xFF632F1F,0xFF733723,0xFF7F3B2B, 38 0xFF231307,0xFF2F170B,0xFF3B1F0F,0xFF4B2313,0xFF572B17,0xFF632F1F,0xFF733723,0xFF7F3B2B,
39 0xFF8F4333,0xFF9F4F33,0xFFAF632F,0xFFBF772F,0xFFCF8F2B,0xFFDFAB27,0xFFEFCB1F,0xFFFFF31B, 39 0xFF8F4333,0xFF9F4F33,0xFFAF632F,0xFFBF772F,0xFFCF8F2B,0xFFDFAB27,0xFFEFCB1F,0xFFFFF31B,
40 0xFF0B0700,0xFF1B1300,0xFF2B230F,0xFF372B13,0xFF47331B,0xFF533723,0xFF633F2B,0xFF6F4733, 40 0xFF0B0700,0xFF1B1300,0xFF2B230F,0xFF372B13,0xFF47331B,0xFF533723,0xFF633F2B,0xFF6F4733,
41 0xFF7F533F,0xFF8B5F47,0xFF9B6B53,0xFFA77B5F,0xFFB7876B,0xFFC3937B,0xFFD3A38B,0xFFE3B397, 41 0xFF7F533F,0xFF8B5F47,0xFF9B6B53,0xFFA77B5F,0xFFB7876B,0xFFC3937B,0xFFD3A38B,0xFFE3B397,
42 0xFFAB8BA3,0xFF9F7F97,0xFF937387,0xFF8B677B,0xFF7F5B6F,0xFF775363,0xFF6B4B57,0xFF5F3F4B, 42 0xFFAB8BA3,0xFF9F7F97,0xFF937387,0xFF8B677B,0xFF7F5B6F,0xFF775363,0xFF6B4B57,0xFF5F3F4B,
43 0xFF573743,0xFF4B2F37,0xFF43272F,0xFF371F23,0xFF2B171B,0xFF231313,0xFF170B0B,0xFF0F0707, 43 0xFF573743,0xFF4B2F37,0xFF43272F,0xFF371F23,0xFF2B171B,0xFF231313,0xFF170B0B,0xFF0F0707,
44 0xFFBB739F,0xFFAF6B8F,0xFFA35F83,0xFF975777,0xFF8B4F6B,0xFF7F4B5F,0xFF734353,0xFF6B3B4B, 44 0xFFBB739F,0xFFAF6B8F,0xFFA35F83,0xFF975777,0xFF8B4F6B,0xFF7F4B5F,0xFF734353,0xFF6B3B4B,
45 0xFF5F333F,0xFF532B37,0xFF47232B,0xFF3B1F23,0xFF2F171B,0xFF231313,0xFF170B0B,0xFF0F0707, 45 0xFF5F333F,0xFF532B37,0xFF47232B,0xFF3B1F23,0xFF2F171B,0xFF231313,0xFF170B0B,0xFF0F0707,
46 0xFFDBC3BB,0xFFCBB3A7,0xFFBFA39B,0xFFAF978B,0xFFA3877B,0xFF977B6F,0xFF876F5F,0xFF7B6353, 46 0xFFDBC3BB,0xFFCBB3A7,0xFFBFA39B,0xFFAF978B,0xFFA3877B,0xFF977B6F,0xFF876F5F,0xFF7B6353,
47 0xFF6B5747,0xFF5F4B3B,0xFF533F33,0xFF433327,0xFF372B1F,0xFF271F17,0xFF1B130F,0xFF0F0B07, 47 0xFF6B5747,0xFF5F4B3B,0xFF533F33,0xFF433327,0xFF372B1F,0xFF271F17,0xFF1B130F,0xFF0F0B07,
48 0xFF6F837B,0xFF677B6F,0xFF5F7367,0xFF576B5F,0xFF4F6357,0xFF475B4F,0xFF3F5347,0xFF374B3F, 48 0xFF6F837B,0xFF677B6F,0xFF5F7367,0xFF576B5F,0xFF4F6357,0xFF475B4F,0xFF3F5347,0xFF374B3F,
49 0xFF2F4337,0xFF2B3B2F,0xFF233327,0xFF1F2B1F,0xFF172317,0xFF0F1B13,0xFF0B130B,0xFF070B07, 49 0xFF2F4337,0xFF2B3B2F,0xFF233327,0xFF1F2B1F,0xFF172317,0xFF0F1B13,0xFF0B130B,0xFF070B07,
50 0xFFFFF31B,0xFFEFDF17,0xFFDBCB13,0xFFCBB70F,0xFFBBA70F,0xFFAB970B,0xFF9B8307,0xFF8B7307, 50 0xFFFFF31B,0xFFEFDF17,0xFFDBCB13,0xFFCBB70F,0xFFBBA70F,0xFFAB970B,0xFF9B8307,0xFF8B7307,
51 0xFF7B6307,0xFF6B5300,0xFF5B4700,0xFF4B3700,0xFF3B2B00,0xFF2B1F00,0xFF1B0F00,0xFF0B0700, 51 0xFF7B6307,0xFF6B5300,0xFF5B4700,0xFF4B3700,0xFF3B2B00,0xFF2B1F00,0xFF1B0F00,0xFF0B0700,
52 0xFF0000FF,0xFF0B0BEF,0xFF1313DF,0xFF1B1BCF,0xFF2323BF,0xFF2B2BAF,0xFF2F2F9F,0xFF2F2F8F, 52 0xFF0000FF,0xFF0B0BEF,0xFF1313DF,0xFF1B1BCF,0xFF2323BF,0xFF2B2BAF,0xFF2F2F9F,0xFF2F2F8F,
53 0xFF2F2F7F,0xFF2F2F6F,0xFF2F2F5F,0xFF2B2B4F,0xFF23233F,0xFF1B1B2F,0xFF13131F,0xFF0B0B0F, 53 0xFF2F2F7F,0xFF2F2F6F,0xFF2F2F5F,0xFF2B2B4F,0xFF23233F,0xFF1B1B2F,0xFF13131F,0xFF0B0B0F,
54 0xFF2B0000,0xFF3B0000,0xFF4B0700,0xFF5F0700,0xFF6F0F00,0xFF7F1707,0xFF931F07,0xFFA3270B, 54 0xFF2B0000,0xFF3B0000,0xFF4B0700,0xFF5F0700,0xFF6F0F00,0xFF7F1707,0xFF931F07,0xFFA3270B,
55 0xFFB7330F,0xFFC34B1B,0xFFCF632B,0xFFDB7F3B,0xFFE3974F,0xFFE7AB5F,0xFFEFBF77,0xFFF7D38B, 55 0xFFB7330F,0xFFC34B1B,0xFFCF632B,0xFFDB7F3B,0xFFE3974F,0xFFE7AB5F,0xFFEFBF77,0xFFF7D38B,
56 0xFFA77B3B,0xFFB79B37,0xFFC7C337,0xFFE7E357,0xFF7FBFFF,0xFFABE7FF,0xFFD7FFFF,0xFF670000, 56 0xFFA77B3B,0xFFB79B37,0xFFC7C337,0xFFE7E357,0xFF7FBFFF,0xFFABE7FF,0xFFD7FFFF,0xFF670000,
57 0xFF8B0000,0xFFB30000,0xFFD70000,0xFFFF0000,0xFFFFF393,0xFFFFF7C7,0xFFFFFFFF,0x009F5B53 57 0xFF8B0000,0xFFB30000,0xFFD70000,0xFFFF0000,0xFFFFF393,0xFFFFF7C7,0xFFFFFFFF,0x009F5B53
58}; 58};
59 59
60bool CImageLoaderLMP::isALoadableFileExtension(const io::path& filename) const 60bool CImageLoaderLMP::isALoadableFileExtension(const io::path& filename) const
61{ 61{
62 return core::hasFileExtension ( filename, "lmp" ); 62 return core::hasFileExtension ( filename, "lmp" );
63} 63}
64 64
65 65
66bool CImageLoaderLMP::isALoadableFileFormat(irr::io::IReadFile* file) const 66bool CImageLoaderLMP::isALoadableFileFormat(irr::io::IReadFile* file) const
67{ 67{
68 return false; 68 return false;
69} 69}
70 70
71/*! 71/*!
72 Quake1, Quake2, Hallife lmp texture 72 Quake1, Quake2, Hallife lmp texture
73*/ 73*/
74IImage* CImageLoaderLMP::loadImage(irr::io::IReadFile* file) const 74IImage* CImageLoaderLMP::loadImage(irr::io::IReadFile* file) const
75{ 75{
76 SLMPHeader header; 76 SLMPHeader header;
77 77
78 file->seek(0); 78 file->seek(0);
79 file->read(&header, sizeof(header)); 79 file->read(&header, sizeof(header));
80 80
81 // maybe palette file 81 // maybe palette file
82 u32 rawtexsize = header.width * header.height; 82 u32 rawtexsize = header.width * header.height;
83 if ( rawtexsize + sizeof ( header ) != (u32)file->getSize() ) 83 if ( rawtexsize + sizeof ( header ) != (u32)file->getSize() )
84 return 0; 84 return 0;
85 85
86 u8 *rawtex = new u8 [ rawtexsize ]; 86 u8 *rawtex = new u8 [ rawtexsize ];
87 87
88 file->read(rawtex, rawtexsize); 88 file->read(rawtex, rawtexsize);
89 89
90 IImage* image = new CImage(ECF_A8R8G8B8, core::dimension2d<u32>(header.width, header.height)); 90 IImage* image = new CImage(ECF_A8R8G8B8, core::dimension2d<u32>(header.width, header.height));
91 91
92 CColorConverter::convert8BitTo32Bit(rawtex, (u8*)image->lock(), header.width, header.height, (u8*) colormap_h, 0, false); 92 CColorConverter::convert8BitTo32Bit(rawtex, (u8*)image->lock(), header.width, header.height, (u8*) colormap_h, 0, false);
93 image->unlock(); 93 image->unlock();
94 94
95 delete [] rawtex; 95 delete [] rawtex;
96 96
97 return image; 97 return image;
98} 98}
99 99
100 100
101IImageLoader* createImageLoaderLMP() 101IImageLoader* createImageLoaderLMP()
102{ 102{
103 return new irr::video::CImageLoaderLMP(); 103 return new irr::video::CImageLoaderLMP();
104} 104}
105 105
106#endif 106#endif
107 107
108#ifdef _IRR_COMPILE_WITH_WAL_LOADER_ 108#ifdef _IRR_COMPILE_WITH_WAL_LOADER_
109 109
110// Palette quake2 demo pics/colormap.pcx, last is transparent 110// Palette quake2 demo pics/colormap.pcx, last is transparent
111static const u32 colormap_pcx[256] = { 111static const u32 colormap_pcx[256] = {
112 0xFF000000,0xFF0F0F0F,0xFF1F1F1F,0xFF2F2F2F,0xFF3F3F3F,0xFF4B4B4B,0xFF5B5B5B,0xFF6B6B6B, 112 0xFF000000,0xFF0F0F0F,0xFF1F1F1F,0xFF2F2F2F,0xFF3F3F3F,0xFF4B4B4B,0xFF5B5B5B,0xFF6B6B6B,
113 0xFF7B7B7B,0xFF8B8B8B,0xFF9B9B9B,0xFFABABAB,0xFFBBBBBB,0xFFCBCBCB,0xFFDBDBDB,0xFFEBEBEB, 113 0xFF7B7B7B,0xFF8B8B8B,0xFF9B9B9B,0xFFABABAB,0xFFBBBBBB,0xFFCBCBCB,0xFFDBDBDB,0xFFEBEBEB,
114 0xFF634B23,0xFF5B431F,0xFF533F1F,0xFF4F3B1B,0xFF47371B,0xFF3F2F17,0xFF3B2B17,0xFF332713, 114 0xFF634B23,0xFF5B431F,0xFF533F1F,0xFF4F3B1B,0xFF47371B,0xFF3F2F17,0xFF3B2B17,0xFF332713,
115 0xFF2F2313,0xFF2B1F13,0xFF271B0F,0xFF23170F,0xFF1B130B,0xFF170F0B,0xFF130F07,0xFF0F0B07, 115 0xFF2F2313,0xFF2B1F13,0xFF271B0F,0xFF23170F,0xFF1B130B,0xFF170F0B,0xFF130F07,0xFF0F0B07,
116 0xFF5F5F6F,0xFF5B5B67,0xFF5B535F,0xFF574F5B,0xFF534B53,0xFF4F474B,0xFF473F43,0xFF3F3B3B, 116 0xFF5F5F6F,0xFF5B5B67,0xFF5B535F,0xFF574F5B,0xFF534B53,0xFF4F474B,0xFF473F43,0xFF3F3B3B,
117 0xFF3B3737,0xFF332F2F,0xFF2F2B2B,0xFF272727,0xFF232323,0xFF1B1B1B,0xFF171717,0xFF131313, 117 0xFF3B3737,0xFF332F2F,0xFF2F2B2B,0xFF272727,0xFF232323,0xFF1B1B1B,0xFF171717,0xFF131313,
118 0xFF8F7753,0xFF7B6343,0xFF735B3B,0xFF674F2F,0xFFCF974B,0xFFA77B3B,0xFF8B672F,0xFF6F5327, 118 0xFF8F7753,0xFF7B6343,0xFF735B3B,0xFF674F2F,0xFFCF974B,0xFFA77B3B,0xFF8B672F,0xFF6F5327,
119 0xFFEB9F27,0xFFCB8B23,0xFFAF771F,0xFF93631B,0xFF774F17,0xFF5B3B0F,0xFF3F270B,0xFF231707, 119 0xFFEB9F27,0xFFCB8B23,0xFFAF771F,0xFF93631B,0xFF774F17,0xFF5B3B0F,0xFF3F270B,0xFF231707,
120 0xFFA73B2B,0xFF9F2F23,0xFF972B1B,0xFF8B2713,0xFF7F1F0F,0xFF73170B,0xFF671707,0xFF571300, 120 0xFFA73B2B,0xFF9F2F23,0xFF972B1B,0xFF8B2713,0xFF7F1F0F,0xFF73170B,0xFF671707,0xFF571300,
121 0xFF4B0F00,0xFF430F00,0xFF3B0F00,0xFF330B00,0xFF2B0B00,0xFF230B00,0xFF1B0700,0xFF130700, 121 0xFF4B0F00,0xFF430F00,0xFF3B0F00,0xFF330B00,0xFF2B0B00,0xFF230B00,0xFF1B0700,0xFF130700,
122 0xFF7B5F4B,0xFF735743,0xFF6B533F,0xFF674F3B,0xFF5F4737,0xFF574333,0xFF533F2F,0xFF4B372B, 122 0xFF7B5F4B,0xFF735743,0xFF6B533F,0xFF674F3B,0xFF5F4737,0xFF574333,0xFF533F2F,0xFF4B372B,
123 0xFF433327,0xFF3F2F23,0xFF37271B,0xFF2F2317,0xFF271B13,0xFF1F170F,0xFF170F0B,0xFF0F0B07, 123 0xFF433327,0xFF3F2F23,0xFF37271B,0xFF2F2317,0xFF271B13,0xFF1F170F,0xFF170F0B,0xFF0F0B07,
124 0xFF6F3B17,0xFF5F3717,0xFF532F17,0xFF432B17,0xFF372313,0xFF271B0F,0xFF1B130B,0xFF0F0B07, 124 0xFF6F3B17,0xFF5F3717,0xFF532F17,0xFF432B17,0xFF372313,0xFF271B0F,0xFF1B130B,0xFF0F0B07,
125 0xFFB35B4F,0xFFBF7B6F,0xFFCB9B93,0xFFD7BBB7,0xFFCBD7DF,0xFFB3C7D3,0xFF9FB7C3,0xFF87A7B7, 125 0xFFB35B4F,0xFFBF7B6F,0xFFCB9B93,0xFFD7BBB7,0xFFCBD7DF,0xFFB3C7D3,0xFF9FB7C3,0xFF87A7B7,
126 0xFF7397A7,0xFF5B879B,0xFF47778B,0xFF2F677F,0xFF17536F,0xFF134B67,0xFF0F435B,0xFF0B3F53, 126 0xFF7397A7,0xFF5B879B,0xFF47778B,0xFF2F677F,0xFF17536F,0xFF134B67,0xFF0F435B,0xFF0B3F53,
127 0xFF07374B,0xFF072F3F,0xFF072733,0xFF001F2B,0xFF00171F,0xFF000F13,0xFF00070B,0xFF000000, 127 0xFF07374B,0xFF072F3F,0xFF072733,0xFF001F2B,0xFF00171F,0xFF000F13,0xFF00070B,0xFF000000,
128 0xFF8B5757,0xFF834F4F,0xFF7B4747,0xFF734343,0xFF6B3B3B,0xFF633333,0xFF5B2F2F,0xFF572B2B, 128 0xFF8B5757,0xFF834F4F,0xFF7B4747,0xFF734343,0xFF6B3B3B,0xFF633333,0xFF5B2F2F,0xFF572B2B,
129 0xFF4B2323,0xFF3F1F1F,0xFF331B1B,0xFF2B1313,0xFF1F0F0F,0xFF130B0B,0xFF0B0707,0xFF000000, 129 0xFF4B2323,0xFF3F1F1F,0xFF331B1B,0xFF2B1313,0xFF1F0F0F,0xFF130B0B,0xFF0B0707,0xFF000000,
130 0xFF979F7B,0xFF8F9773,0xFF878B6B,0xFF7F8363,0xFF777B5F,0xFF737357,0xFF6B6B4F,0xFF636347, 130 0xFF979F7B,0xFF8F9773,0xFF878B6B,0xFF7F8363,0xFF777B5F,0xFF737357,0xFF6B6B4F,0xFF636347,
131 0xFF5B5B43,0xFF4F4F3B,0xFF434333,0xFF37372B,0xFF2F2F23,0xFF23231B,0xFF171713,0xFF0F0F0B, 131 0xFF5B5B43,0xFF4F4F3B,0xFF434333,0xFF37372B,0xFF2F2F23,0xFF23231B,0xFF171713,0xFF0F0F0B,
132 0xFF9F4B3F,0xFF934337,0xFF8B3B2F,0xFF7F3727,0xFF772F23,0xFF6B2B1B,0xFF632317,0xFF571F13, 132 0xFF9F4B3F,0xFF934337,0xFF8B3B2F,0xFF7F3727,0xFF772F23,0xFF6B2B1B,0xFF632317,0xFF571F13,
133 0xFF4F1B0F,0xFF43170B,0xFF37130B,0xFF2B0F07,0xFF1F0B07,0xFF170700,0xFF0B0000,0xFF000000, 133 0xFF4F1B0F,0xFF43170B,0xFF37130B,0xFF2B0F07,0xFF1F0B07,0xFF170700,0xFF0B0000,0xFF000000,
134 0xFF777BCF,0xFF6F73C3,0xFF676BB7,0xFF6363A7,0xFF5B5B9B,0xFF53578F,0xFF4B4F7F,0xFF474773, 134 0xFF777BCF,0xFF6F73C3,0xFF676BB7,0xFF6363A7,0xFF5B5B9B,0xFF53578F,0xFF4B4F7F,0xFF474773,
135 0xFF3F3F67,0xFF373757,0xFF2F2F4B,0xFF27273F,0xFF231F2F,0xFF1B1723,0xFF130F17,0xFF0B0707, 135 0xFF3F3F67,0xFF373757,0xFF2F2F4B,0xFF27273F,0xFF231F2F,0xFF1B1723,0xFF130F17,0xFF0B0707,
136 0xFF9BAB7B,0xFF8F9F6F,0xFF879763,0xFF7B8B57,0xFF73834B,0xFF677743,0xFF5F6F3B,0xFF576733, 136 0xFF9BAB7B,0xFF8F9F6F,0xFF879763,0xFF7B8B57,0xFF73834B,0xFF677743,0xFF5F6F3B,0xFF576733,
137 0xFF4B5B27,0xFF3F4F1B,0xFF374313,0xFF2F3B0B,0xFF232F07,0xFF1B2300,0xFF131700,0xFF0B0F00, 137 0xFF4B5B27,0xFF3F4F1B,0xFF374313,0xFF2F3B0B,0xFF232F07,0xFF1B2300,0xFF131700,0xFF0B0F00,
138 0xFF00FF00,0xFF23E70F,0xFF3FD31B,0xFF53BB27,0xFF5FA72F,0xFF5F8F33,0xFF5F7B33,0xFFFFFFFF, 138 0xFF00FF00,0xFF23E70F,0xFF3FD31B,0xFF53BB27,0xFF5FA72F,0xFF5F8F33,0xFF5F7B33,0xFFFFFFFF,
139 0xFFFFFFD3,0xFFFFFFA7,0xFFFFFF7F,0xFFFFFF53,0xFFFFFF27,0xFFFFEB1F,0xFFFFD717,0xFFFFBF0F, 139 0xFFFFFFD3,0xFFFFFFA7,0xFFFFFF7F,0xFFFFFF53,0xFFFFFF27,0xFFFFEB1F,0xFFFFD717,0xFFFFBF0F,
140 0xFFFFAB07,0xFFFF9300,0xFFEF7F00,0xFFE36B00,0xFFD35700,0xFFC74700,0xFFB73B00,0xFFAB2B00, 140 0xFFFFAB07,0xFFFF9300,0xFFEF7F00,0xFFE36B00,0xFFD35700,0xFFC74700,0xFFB73B00,0xFFAB2B00,
141 0xFF9B1F00,0xFF8F1700,0xFF7F0F00,0xFF730700,0xFF5F0000,0xFF470000,0xFF2F0000,0xFF1B0000, 141 0xFF9B1F00,0xFF8F1700,0xFF7F0F00,0xFF730700,0xFF5F0000,0xFF470000,0xFF2F0000,0xFF1B0000,
142 0xFFEF0000,0xFF3737FF,0xFFFF0000,0xFF0000FF,0xFF2B2B23,0xFF1B1B17,0xFF13130F,0xFFEB977F, 142 0xFFEF0000,0xFF3737FF,0xFFFF0000,0xFF0000FF,0xFF2B2B23,0xFF1B1B17,0xFF13130F,0xFFEB977F,
143 0xFFC37353,0xFF9F5733,0xFF7B3F1B,0xFFEBD3C7,0xFFC7AB9B,0xFFA78B77,0xFF876B57,0x009F5B53 143 0xFFC37353,0xFF9F5733,0xFF7B3F1B,0xFFEBD3C7,0xFFC7AB9B,0xFFA78B77,0xFF876B57,0x009F5B53
144}; 144};
145 145
146/*! 146/*!
147 Halflife 147 Halflife
148*/ 148*/
149bool CImageLoaderWAL2::isALoadableFileExtension(const io::path& filename) const 149bool CImageLoaderWAL2::isALoadableFileExtension(const io::path& filename) const
150{ 150{
151 // embedded in Wad(WAD3 format). originally it has no extension 151 // embedded in Wad(WAD3 format). originally it has no extension
152 return core::hasFileExtension ( filename, "wal2" ); 152 return core::hasFileExtension ( filename, "wal2" );
153} 153}
154 154
155 155
156bool CImageLoaderWAL2::isALoadableFileFormat(irr::io::IReadFile* file) const 156bool CImageLoaderWAL2::isALoadableFileFormat(irr::io::IReadFile* file) const
157{ 157{
158 return false; 158 return false;
159} 159}
160 160
161/* 161/*
162 Halflite Texture WAD 162 Halflite Texture WAD
163*/ 163*/
164IImage* CImageLoaderWAL2::loadImage(irr::io::IReadFile* file) const 164IImage* CImageLoaderWAL2::loadImage(irr::io::IReadFile* file) const
165{ 165{
166 miptex_halflife header; 166 miptex_halflife header;
167 167
168 file->seek(0); 168 file->seek(0);
169 file->read(&header, sizeof(header)); 169 file->read(&header, sizeof(header));
170 170
171#ifdef __BIG_ENDIAN__ 171#ifdef __BIG_ENDIAN__
172 header.width = os::Byteswap::byteswap(header.width); 172 header.width = os::Byteswap::byteswap(header.width);
173 header.height = os::Byteswap::byteswap(header.height); 173 header.height = os::Byteswap::byteswap(header.height);
174#endif 174#endif
175 175
176 // palette 176 // palette
177 //u32 paletteofs = header.mipmap[0] + ((rawtexsize * 85) >> 6) + 2; 177 //u32 paletteofs = header.mipmap[0] + ((rawtexsize * 85) >> 6) + 2;
178 u32 *pal = new u32 [ 192 + 256 ]; 178 u32 *pal = new u32 [ 192 + 256 ];
179 u8 *s = (u8*) pal; 179 u8 *s = (u8*) pal;
180 180
181 file->seek ( file->getSize() - 768 - 2 ); 181 file->seek ( file->getSize() - 768 - 2 );
182 file->read ( s, 768 ); 182 file->read ( s, 768 );
183 u32 i; 183 u32 i;
184 184
185 for ( i = 0; i < 256; ++i, s+= 3 ) 185 for ( i = 0; i < 256; ++i, s+= 3 )
186 { 186 {
187 pal [ 192 + i ] = 0xFF000000 | s[0] << 16 | s[1] << 8 | s[2]; 187 pal [ 192 + i ] = 0xFF000000 | s[0] << 16 | s[1] << 8 | s[2];
188 } 188 }
189 189
190 ECOLOR_FORMAT format = ECF_R8G8B8; 190 ECOLOR_FORMAT format = ECF_R8G8B8;
191 191
192 // transparency in filename;-) funny. rgb:0x0000FF is colorkey 192 // transparency in filename;-) funny. rgb:0x0000FF is colorkey
193 if ( file->getFileName().findFirst ( '{' ) >= 0 ) 193 if ( file->getFileName().findFirst ( '{' ) >= 0 )
194 { 194 {
195 format = ECF_A8R8G8B8; 195 format = ECF_A8R8G8B8;
196 pal [ 192 + 255 ] &= 0x00FFFFFF; 196 pal [ 192 + 255 ] &= 0x00FFFFFF;
197 } 197 }
198 198
199 u32 rawtexsize = header.width * header.height; 199 u32 rawtexsize = header.width * header.height;
200 200
201 201
202 u8 *rawtex = new u8 [ rawtexsize ]; 202 u8 *rawtex = new u8 [ rawtexsize ];
203 203
204 file->seek ( header.mipmap[0] ); 204 file->seek ( header.mipmap[0] );
205 file->read(rawtex, rawtexsize); 205 file->read(rawtex, rawtexsize);
206 206
207 IImage* image = new CImage(format, core::dimension2d<u32>(header.width, header.height)); 207 IImage* image = new CImage(format, core::dimension2d<u32>(header.width, header.height));
208 208
209 switch ( format ) 209 switch ( format )
210 { 210 {
211 case ECF_R8G8B8: 211 case ECF_R8G8B8:
212 CColorConverter::convert8BitTo24Bit(rawtex, (u8*)image->lock(), header.width, header.height, (u8*) pal + 768, 0, false); 212 CColorConverter::convert8BitTo24Bit(rawtex, (u8*)image->lock(), header.width, header.height, (u8*) pal + 768, 0, false);
213 break; 213 break;
214 case ECF_A8R8G8B8: 214 case ECF_A8R8G8B8:
215 CColorConverter::convert8BitTo32Bit(rawtex, (u8*)image->lock(), header.width, header.height, (u8*) pal + 768, 0, false); 215 CColorConverter::convert8BitTo32Bit(rawtex, (u8*)image->lock(), header.width, header.height, (u8*) pal + 768, 0, false);
216 break; 216 break;
217 } 217 }
218 218
219 image->unlock(); 219 image->unlock();
220 220
221 delete [] rawtex; 221 delete [] rawtex;
222 delete [] pal; 222 delete [] pal;
223 223
224 return image; 224 return image;
225} 225}
226 226
227bool CImageLoaderWAL::isALoadableFileExtension(const io::path& filename) const 227bool CImageLoaderWAL::isALoadableFileExtension(const io::path& filename) const
228{ 228{
229 return core::hasFileExtension ( filename, "wal" ); 229 return core::hasFileExtension ( filename, "wal" );
230} 230}
231 231
232 232
233bool CImageLoaderWAL::isALoadableFileFormat(irr::io::IReadFile* file) const 233bool CImageLoaderWAL::isALoadableFileFormat(irr::io::IReadFile* file) const
234{ 234{
235 return false; 235 return false;
236} 236}
237 237
238 238
239/*! 239/*!
240 quake2 240 quake2
241*/ 241*/
242IImage* CImageLoaderWAL::loadImage(irr::io::IReadFile* file) const 242IImage* CImageLoaderWAL::loadImage(irr::io::IReadFile* file) const
243{ 243{
244 miptex_quake2 header; 244 miptex_quake2 header;
245 245
246 file->seek(0); 246 file->seek(0);
247 file->read(&header, sizeof(header)); 247 file->read(&header, sizeof(header));
248 248
249#ifdef __BIG_ENDIAN__ 249#ifdef __BIG_ENDIAN__
250 header.width = os::Byteswap::byteswap(header.width); 250 header.width = os::Byteswap::byteswap(header.width);
251 header.height = os::Byteswap::byteswap(header.height); 251 header.height = os::Byteswap::byteswap(header.height);
252#endif 252#endif
253 253
254 u32 rawtexsize = header.width * header.height; 254 u32 rawtexsize = header.width * header.height;
255 255
256 u8 *rawtex = new u8 [ rawtexsize ]; 256 u8 *rawtex = new u8 [ rawtexsize ];
257 257
258 file->seek ( header.mipmap[0] ); 258 file->seek ( header.mipmap[0] );
259 file->read(rawtex, rawtexsize); 259 file->read(rawtex, rawtexsize);
260 260
261 IImage* image = new CImage(ECF_A8R8G8B8, core::dimension2d<u32>(header.width, header.height)); 261 IImage* image = new CImage(ECF_A8R8G8B8, core::dimension2d<u32>(header.width, header.height));
262 262
263 CColorConverter::convert8BitTo32Bit(rawtex, (u8*)image->lock(), header.width, header.height, (u8*) colormap_pcx, 0, false); 263 CColorConverter::convert8BitTo32Bit(rawtex, (u8*)image->lock(), header.width, header.height, (u8*) colormap_pcx, 0, false);
264 image->unlock(); 264 image->unlock();
265 265
266 delete [] rawtex; 266 delete [] rawtex;
267 267
268 return image; 268 return image;
269} 269}
270 270
271IImageLoader* createImageLoaderWAL() 271IImageLoader* createImageLoaderWAL()
272{ 272{
273 return new irr::video::CImageLoaderWAL(); 273 return new irr::video::CImageLoaderWAL();
274} 274}
275 275
276IImageLoader* createImageLoaderHalfLife() 276IImageLoader* createImageLoaderHalfLife()
277{ 277{
278 return new irr::video::CImageLoaderWAL2(); 278 return new irr::video::CImageLoaderWAL2();
279} 279}
280 280
281#endif 281#endif
282 282
283} // end namespace video 283} // end namespace video
284} // end namespace irr 284} // end namespace irr
285 285