engine/EngineVideoTextureManager.c
/*	Handles 8bit source data, then passes it to LoadImage32
*/
Handles 8bit source data, then passes it to LoadImage32
Handles 8bit source data then passes it to LoadImage32
void TexMgr_LoadImage8(gltexture_t *glt, uint8_t *data)
{
	extern		cvar_t	gl_fullbrights;
	bool				padw = false,padh = false;
	uint8_t				padbyte;
	unsigned	int		i,*usepal;
	if (glt->flags & TEXPREF_ALPHA && !(glt->flags & TEXPREF_CONCHARS))
	{
		for (i = 0; i < glt->width*glt->height; i++)
			if (data[i] == 255) 
				break;
		if (i == glt->width*glt->height)
			glt->flags -= TEXPREF_ALPHA;
	}
	if (glt->flags & TEXPREF_FULLBRIGHT)
	{
		usepal = d_8to24table_fbright;
		padbyte = 0;
	}
	else if (glt->flags & TEXPREF_NOBRIGHT && gl_fullbrights.value)
	{
		usepal = d_8to24table_nobright;
		padbyte = 0;
	}
	else if (glt->flags & TEXPREF_CONCHARS)
	{
		usepal = d_8to24table_conchars;
		padbyte = 0;
	}
	else
	{
		usepal = d_8to24table;
		padbyte = 255;
	}
	if (glt->flags & TEXPREF_PAD)
	{
		if (glt->width < TexMgr_SafeTextureSize(glt->width))
		{
			data = TexMgr_PadImageW (data, glt->width, glt->height, padbyte);
			glt->width = TexMgr_Pad(glt->width);
			padw = true;
		}
		if (glt->height < TexMgr_SafeTextureSize(glt->height))
		{
			data = TexMgr_PadImageH (data, glt->width, glt->height, padbyte);
			glt->height = TexMgr_Pad(glt->height);
			padh = true;
		}
	}
	data = (byte *)TexMgr_8to32(data, glt->width * glt->height, usepal);
	if (glt->flags & TEXPREF_ALPHA)
		TexMgr_AlphaEdgeFix (data, glt->width, glt->height);
	else
	{
		if (padw)
			TexMgr_PadEdgeFixW (data, glt->source_width, glt->source_height);
		if (padh)
			TexMgr_PadEdgeFixH (data, glt->source_width, glt->source_height);
	}
	TexMgr_LoadImage32 (glt, data);
}
void TexMgr_LoadImage8 ( gltexture_t * glt , uint8_t * data ) { extern cvar_t gl_fullbrights ; bool padw = false , padh = false ; uint8_t padbyte ; unsigned int i , * usepal ; if ( glt -> flags & TEXPREF_ALPHA && ! ( glt -> flags & TEXPREF_CONCHARS ) ) { for ( i = 0 ; i < glt -> width * glt -> height ; i ++ ) if ( data [ i ] == 255 ) break ; if ( i == glt -> width * glt -> height ) glt -> flags -= TEXPREF_ALPHA ; } if ( glt -> flags & TEXPREF_FULLBRIGHT ) { usepal = d_8to24table_fbright ; padbyte = 0 ; } else if ( glt -> flags & TEXPREF_NOBRIGHT && gl_fullbrights . value ) { usepal = d_8to24table_nobright ; padbyte = 0 ; } else if ( glt -> flags & TEXPREF_CONCHARS ) { usepal = d_8to24table_conchars ; padbyte = 0 ; } else { usepal = d_8to24table ; padbyte = 255 ; } if ( glt -> flags & TEXPREF_PAD ) { if ( glt -> width < TexMgr_SafeTextureSize ( glt -> width ) ) { data = TexMgr_PadImageW ( data , glt -> width , glt -> height , padbyte ) ; glt -> width = TexMgr_Pad ( glt -> width ) ; padw = true ; } if ( glt -> height < TexMgr_SafeTextureSize ( glt -> height ) ) { data = TexMgr_PadImageH ( data , glt -> width , glt -> height , padbyte ) ; glt -> height = TexMgr_Pad ( glt -> height ) ; padh = true ; } } data = ( byte * ) TexMgr_8to32 ( data , glt -> width * glt -> height , usepal ) ; if ( glt -> flags & TEXPREF_ALPHA ) TexMgr_AlphaEdgeFix ( data , glt -> width , glt -> height ) ; else { if ( padw ) TexMgr_PadEdgeFixW ( data , glt -> source_width , glt -> source_height ) ; if ( padh ) TexMgr_PadEdgeFixH ( data , glt -> source_width , glt -> source_height ) ; } TexMgr_LoadImage32 ( glt , data ) ; }
Handles 8bit source data, then passes it to LoadImage32
Handles 8bit source data then passes it to LoadImage32
// detect FALSE alpha cases //transparent index // choose palette and padbyte // pad each dimention, but only if it's not going to be downsampled later // convert to 32bit // fix edges // upload it