Ejemplo n.º 1
0
//----------------------------------------------------------------------------
//! @brief	  	ミキシングするビデオストリームの背景色を設定する
//! @param		col : 設定する背景色
//----------------------------------------------------------------------------
void __stdcall tTVPDSMixerVideoOverlay::SetMixingMovieBGColor( unsigned long col )
{
	HRESULT			hr;
	COLORREF	cr = ChangeEndian32(col<<8);
	if(FAILED(hr = MixerControl()->SetBackgroundClr( cr )) )
		ThrowDShowException(L"Failed to set IVMRMixerControl9::SetBackgroundClr.", hr);
}
Ejemplo n.º 2
0
int CRlePack::LoadFile( const char* a_pcFilename, int a_iNumColors )
{
	FILE* f;
	
	f = fopen( a_pcFilename, "rb" );
	if (f==NULL)
	{
		debug( "Can't open file '%s'.\n", a_pcFilename );
		return -1;
	}
	
	fseek( f, 0, SEEK_END );
	long iFileSize = ftell ( f );
	p->m_pData = malloc( iFileSize );
	if ( NULL == p->m_pData )
	{
		fclose( f );
		return -1;
	}
	
	fseek( f, 0, SEEK_SET );
	int iRead = fread( p->m_pData, 1, iFileSize, f );
	fclose( f );
	
	p->m_iColorCount = gamescreen->format->BitsPerPixel == 8 ? a_iNumColors : 256;
	
	if ( iFileSize != iRead )
	{
		debug( "Warning CRlePack(): iFileSize=%d, iRead=%d\n", iFileSize, iRead );
	}
	
	struct SHeader
	{
		char	acDummy[8];
		Uint32	iDatacount;
	} *poHeader = (SHeader*) p->m_pData;
	
	ChangeEndian32( poHeader->iDatacount );
	debug( "File '%s' contains %d entries.\n", a_pcFilename, poHeader->iDatacount );
	
	if (poHeader->iDatacount>MAXDATACOUNT) poHeader->iDatacount = MAXDATACOUNT;		// Sanity
	
	p->m_iArraysize = poHeader->iDatacount;
	p->m_pSprites = new SRleSprite*[ poHeader->iDatacount ];
	
	char* pcNext = ((char*)p->m_pData) + sizeof(SHeader);
	char* pcEnd = ((char*)p->m_pData) + iFileSize;
	
	while ( pcNext < pcEnd - 4 )
	{
		if ( 0 == strncmp( pcNext, "prop", 4 ) )
		{
			struct SProperty
			{
				char	acName[4];
				Uint32	iSize;
			} *poProperty = (SProperty*) (pcNext+4);
			ChangeEndian32( poProperty->iSize );
			
			pcNext += 4 + sizeof(SProperty) + poProperty->iSize;
		}
		else if ( 0 == strncmp( pcNext, "RLE ", 4 ) )
		{
			struct SRLE
			{
				SRleSprite	oSprite;
			} *poRle = (SRLE*) (pcNext+10);
			poRle->oSprite.color_depth = ConvertEndian16(poRle->oSprite.color_depth);
			poRle->oSprite.w = ConvertEndian16(poRle->oSprite.w);
			poRle->oSprite.h = ConvertEndian16(poRle->oSprite.h);
			poRle->oSprite.size = ConvertEndian32(poRle->oSprite.size);
			
			p->m_pSprites[p->m_iCount] = &(poRle->oSprite);
			p->m_iCount++;
			pcNext += 10 + sizeof( SRLE ) + poRle->oSprite.size;
		}
		else if ( 0 == strncmp( pcNext, "PAL ", 4 ) )
		{
			struct SPAL
			{
				Uint32		iLength1;
				Uint32		iLength;
				SDL_Color	aoColors[256];
			} *poPal = (SPAL*) (pcNext+4);
			ChangeEndian32( poPal->iLength );
			
			int iNumColors = poPal->iLength>1024 ? 1024 : poPal->iLength;
			iNumColors /= 4;
			
			for (int i=0; i< iNumColors; i++)
			{
				p->m_aoPalette[i].r = poPal->aoColors[i].r*4;
				p->m_aoPalette[i].g = poPal->aoColors[i].g*4;
				p->m_aoPalette[i].b = poPal->aoColors[i].b*4;
				p->m_aoPalette[i].unused = 0;
				p->m_aoTintedPalette[i] = p->m_aoPalette[i];
			}
			
			pcNext += 4 + 8 + poPal->iLength;
		}
		else
		{
			struct SUnknown
			{
				Uint32	iSize;
			} *poUnknown = (SUnknown*) (pcNext+4);
			ChangeEndian32( poUnknown->iSize );
			
			debug( "Unknown: '%4s', size: %d\n", pcNext, poUnknown->iSize );
			
			pcNext += 4 + sizeof(SUnknown) + poUnknown->iSize;
		}
	}
	
	return p->m_iCount;
	
#if 0
// #
// # Here's the old implementation or read, left here for reference only.
// #
	
	int datacount;
	
	#define READDW(I) {														\
		unsigned char data[4];														\
		fread( data, 4, 1, f );												\
		(I) = (data[0]<<24) + (data[1]<<16) + (data[2]<<8) + data[3]; }
	#define READW(I) {														\
		unsigned char data[2];														\
		fread( data, 2, 1, f );												\
		(I) = (data[0]<<8) + data[1]; }
	#define READCH(S,C) {													\
		fread( S, C, 1, f ); S[C] = 0; }
	
	fseek( f, 8, SEEK_SET );		// Skip header
	READDW( datacount );
	
	debug( "File '%s' contains %d entries.\n", filename, datacount );
	if (datacount>500) datacount = 500;			// Sanity
	
	p->arraysize = datacount;
	p->sprites = new SRleSprite*[ datacount ];
	
	while( (!feof(f)) && (!ferror(f)) && (datacount>0) )
	{
		char s[10];
		READCH( s, 4 );
		if ( !strcmp( s, "prop" ))				// Found a property
		{
			fseek( f, 4, SEEK_CUR );
			unsigned int propsize;
			READDW( propsize );
			fseek( f, propsize, SEEK_CUR );
		}
		else if (!strcmp( s, "RLE " ))			// Found an SRleSprite
		{
			datacount--;
			
			unsigned int length, bpp, width, height, size;
			
			READDW( length );
			READDW( length );
			READW( bpp );
			READW( width );
			READW( height );
			READDW( size );
			
			SRleSprite* sprite = (SRleSprite*) malloc( sizeof(SRleSprite) + size );
			p->sprites[ p->count ] = sprite;
			(p->count)++;
			sprite->w = width;
			sprite->h = height;
			sprite->color_depth = bpp;
			sprite->size = size;
			fread( sprite->dat, 1, size, f );
		}
		else if (!strcmp( s, "PAL "))			// Found a palette
		{
			datacount--;
			
			unsigned int length, pallength;
			READDW( length );
			READDW( length );
			pallength = length>1024 ? 1024 : length;
			pallength /= 4;
			
			for (unsigned int i=0; i< pallength; i++)
			{
				char c[4];
				fread( c, 4, 1, f );
				p->palette[i].r = c[0]*4;
				p->palette[i].g = c[1]*4;
				p->palette[i].b = c[2]*4;
				p->palette[i].unused = 0;
			}
			
			fseek( f, length - pallength*4, SEEK_CUR );
		}
		else									// Found something else
		{
			debug( "Unknown: %s.", s );
			datacount--;
		
			unsigned int length;
			READDW( length );
			READDW( length );
			fseek( f, length, SEEK_CUR );
		}
	}
	
	fclose( f );
#endif
}