mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2025-01-11 02:45:46 +01:00
engine: common: imagelib: fixed loading BMP files with v4/v5 headers
This commit is contained in:
parent
d2f3b1974e
commit
cd2720ba81
@ -41,7 +41,7 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
|
||||
buf_p = (byte *)buffer;
|
||||
memcpy( &bhdr, buf_p, sizeof( bmp_t ));
|
||||
buf_p += sizeof( bmp_t );
|
||||
buf_p += BI_FILE_HEADER_SIZE + bhdr.bitmapHeaderSize;
|
||||
|
||||
// bogus file header check
|
||||
if( bhdr.reserved0 != 0 ) return false;
|
||||
@ -53,9 +53,9 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
return false;
|
||||
}
|
||||
|
||||
if( bhdr.bitmapHeaderSize != 0x28 )
|
||||
if(!( bhdr.bitmapHeaderSize == 40 || bhdr.bitmapHeaderSize == 108 || bhdr.bitmapHeaderSize == 124 ))
|
||||
{
|
||||
Con_DPrintf( S_ERROR "Image_LoadBMP: invalid header size %i\n", bhdr.bitmapHeaderSize );
|
||||
Con_DPrintf( S_ERROR "Image_LoadBMP: %s have non-standard header size %i\n", name, bhdr.bitmapHeaderSize );
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -187,6 +187,7 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
return false;
|
||||
}
|
||||
|
||||
image.depth = 1;
|
||||
image.size = image.width * image.height * bpp;
|
||||
image.rgba = Mem_Malloc( host.imagepool, image.size );
|
||||
|
||||
@ -313,8 +314,8 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
}
|
||||
|
||||
VectorDivide( reflectivity, ( image.width * image.height ), image.fogParams );
|
||||
if( image.palette ) Image_GetPaletteBMP( image.palette );
|
||||
image.depth = 1;
|
||||
if( image.palette )
|
||||
Image_GetPaletteBMP( image.palette );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ GNU General Public License for more details.
|
||||
========================================================================
|
||||
*/
|
||||
|
||||
#define BI_FILE_HEADER_SIZE 14
|
||||
#define BI_SIZE 40 // size of bitmap info header.
|
||||
#if !defined(BI_RGB)
|
||||
#define BI_RGB 0 // uncompressed RGB bitmap(defined in wingdi.h)
|
||||
|
Loading…
Reference in New Issue
Block a user