mirror of
https://github.com/w23/xash3d-fwgs
synced 2024-12-15 21:50:59 +01:00
engine: common: imagelib: use rgba_t as RGBA palette type.
This commit is contained in:
parent
49445f0663
commit
e96ea719d5
@ -105,6 +105,12 @@ typedef struct imglib_s
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
|
||||
#define BI_SIZE 40 // size of bitmap info header.
|
||||
#if !defined(BI_RGB)
|
||||
#define BI_RGB 0 // uncompressed RGB bitmap(defined in wingdi.h)
|
||||
#endif
|
||||
|
||||
#pragma pack( 1 )
|
||||
typedef struct
|
||||
{
|
||||
|
@ -16,18 +16,6 @@ GNU General Public License for more details.
|
||||
#include "imagelib.h"
|
||||
#include "mathlib.h"
|
||||
|
||||
#define BI_SIZE 40 //size of bitmap info header.
|
||||
#if !XASH_WIN32
|
||||
#define BI_RGB 0
|
||||
|
||||
typedef struct tagRGBQUAD {
|
||||
BYTE rgbBlue;
|
||||
BYTE rgbGreen;
|
||||
BYTE rgbRed;
|
||||
BYTE rgbReserved;
|
||||
} RGBQUAD;
|
||||
#endif
|
||||
|
||||
/*
|
||||
=============
|
||||
Image_LoadBMP
|
||||
@ -36,7 +24,7 @@ Image_LoadBMP
|
||||
qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesize )
|
||||
{
|
||||
byte *buf_p, *pixbuf;
|
||||
byte palette[256][4];
|
||||
rgba_t palette[256];
|
||||
int i, columns, column, rows, row, bpp = 1;
|
||||
int cbPalBytes = 0, padSize = 0, bps = 0;
|
||||
int reflectivity[3] = { 0, 0, 0 };
|
||||
@ -103,9 +91,9 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
if( bhdr.colors == 0 )
|
||||
{
|
||||
bhdr.colors = 256;
|
||||
cbPalBytes = ( 1 << bhdr.bitsPerPixel ) * sizeof( RGBQUAD );
|
||||
cbPalBytes = ( 1 << bhdr.bitsPerPixel ) * sizeof( rgba_t );
|
||||
}
|
||||
else cbPalBytes = bhdr.colors * sizeof( RGBQUAD );
|
||||
else cbPalBytes = bhdr.colors * sizeof( rgba_t );
|
||||
}
|
||||
|
||||
memcpy( palette, buf_p, cbPalBytes );
|
||||
@ -308,7 +296,7 @@ qboolean Image_SaveBMP( const char *name, rgbdata_t *pix )
|
||||
{
|
||||
file_t *pfile = NULL;
|
||||
size_t total_size, cur_size;
|
||||
RGBQUAD rgrgbPalette[256];
|
||||
rgba_t rgrgbPalette[256];
|
||||
dword cbBmpBits;
|
||||
byte *clipbuf = NULL;
|
||||
byte *pb, *pbBmpBits;
|
||||
@ -349,7 +337,7 @@ qboolean Image_SaveBMP( const char *name, rgbdata_t *pix )
|
||||
// after create sprite or lump image, it's just standard requiriments
|
||||
biTrueWidth = ((pix->width + 3) & ~3);
|
||||
cbBmpBits = biTrueWidth * pix->height * pixel_size;
|
||||
cbPalBytes = ( pixel_size == 1 ) ? 256 * sizeof( RGBQUAD ) : 0;
|
||||
cbPalBytes = ( pixel_size == 1 ) ? 256 * sizeof( rgba_t ) : 0;
|
||||
|
||||
// Bogus file header check
|
||||
hdr.id[0] = 'B';
|
||||
@ -379,15 +367,15 @@ qboolean Image_SaveBMP( const char *name, rgbdata_t *pix )
|
||||
// copy over used entries
|
||||
for( i = 0; i < (int)hdr.colors; i++ )
|
||||
{
|
||||
rgrgbPalette[i].rgbRed = *pb++;
|
||||
rgrgbPalette[i].rgbGreen = *pb++;
|
||||
rgrgbPalette[i].rgbBlue = *pb++;
|
||||
rgrgbPalette[i][2] = *pb++;
|
||||
rgrgbPalette[i][1] = *pb++;
|
||||
rgrgbPalette[i][0] = *pb++;
|
||||
|
||||
// bmp feature - can store 32-bit palette if present
|
||||
// some viewers e.g. fimg.exe can show alpha-chanell for it
|
||||
if( pix->type == PF_INDEXED_32 )
|
||||
rgrgbPalette[i].rgbReserved = *pb++;
|
||||
else rgrgbPalette[i].rgbReserved = 0;
|
||||
rgrgbPalette[i][3] = *pb++;
|
||||
else rgrgbPalette[i][3] = 0;
|
||||
}
|
||||
|
||||
// write palette
|
||||
|
@ -25,7 +25,8 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
{
|
||||
int i, columns, rows, row_inc, row, col;
|
||||
byte *buf_p, *pixbuf, *targa_rgba;
|
||||
byte palette[256][4], red = 0, green = 0, blue = 0, alpha = 0;
|
||||
rgba_t palette[256];
|
||||
byte red = 0, green = 0, blue = 0, alpha = 0;
|
||||
int readpixelcount, pixelcount;
|
||||
int reflectivity[3] = { 0, 0, 0 };
|
||||
qboolean compressed;
|
||||
|
Loading…
Reference in New Issue
Block a user