-Image* LoadMDLImageBuff(byte* buffer)
-{
- if(!LoadPalette())
- {
- return 0;
- }
-
- if(!ident_equal(buffer, MDL_IDENT))
- {
- globalErrorStream() << "LoadMDLImage: data has wrong ident\n";
- return 0;
- }
-
- PointerInputStream inputStream(buffer);
- inputStream.seek(4 + 4 + 12 + 12 + 4 + 12);
- //int numskins =
- istream_read_int32_le(inputStream);
- int skinwidth = istream_read_int32_le(inputStream);
- int skinheight = istream_read_int32_le(inputStream);
- inputStream.seek(4 + 4 + 4 + 4 + 4 + 4);
-
- switch(istream_read_int32_le(inputStream))
- {
- case MDL_SKIN_SINGLE:
- break;
- case MDL_SKIN_GROUP:
- int numskins = istream_read_int32_le(inputStream);
- inputStream.seek(numskins * 4);
- break;
- }
-
- RGBAImage* image = new RGBAImage(skinwidth, skinheight);
- unsigned char* pRGBA = image->getRGBAPixels();
-
- for(int i=0; i<(skinheight); i++)
- {
- for(int j=0; j<(skinwidth); j++)
- {
- byte index = istream_read_byte(inputStream);
- *pRGBA++ = mdl_palette[index * 3 + 0];
- *pRGBA++ = mdl_palette[index * 3 + 1];
- *pRGBA++ = mdl_palette[index * 3 + 2];
- *pRGBA++ = 255;
- }
- }
-
- return image;
+Image* LoadMDLImageBuff( byte* buffer ){
+ if ( !LoadPalette() ) {
+ return 0;
+ }
+
+ if ( !ident_equal( buffer, MDL_IDENT ) ) {
+ globalErrorStream() << "LoadMDLImage: data has wrong ident\n";
+ return 0;
+ }
+
+ PointerInputStream inputStream( buffer );
+ inputStream.seek( 4 + 4 + 12 + 12 + 4 + 12 );
+ //int numskins =
+ istream_read_int32_le( inputStream );
+ int skinwidth = istream_read_int32_le( inputStream );
+ int skinheight = istream_read_int32_le( inputStream );
+ inputStream.seek( 4 + 4 + 4 + 4 + 4 + 4 );
+
+ switch ( istream_read_int32_le( inputStream ) )
+ {
+ case MDL_SKIN_SINGLE:
+ break;
+ case MDL_SKIN_GROUP:
+ int numskins = istream_read_int32_le( inputStream );
+ inputStream.seek( numskins * 4 );
+ break;
+ }
+
+ RGBAImage* image = new RGBAImage( skinwidth, skinheight );
+ unsigned char* pRGBA = image->getRGBAPixels();
+
+ for ( int i = 0; i < ( skinheight ); i++ )
+ {
+ for ( int j = 0; j < ( skinwidth ); j++ )
+ {
+ byte index = istream_read_byte( inputStream );
+ *pRGBA++ = mdl_palette[index * 3 + 0];
+ *pRGBA++ = mdl_palette[index * 3 + 1];
+ *pRGBA++ = mdl_palette[index * 3 + 2];
+ *pRGBA++ = 255;
+ }
+ }
+
+ return image;