コード例 #1
0
ファイル: xrMergeLM.cpp プロジェクト: 2asoft/xray
// Rendering of rect
void _rect_register(_rect &R, CDeflector* D, BOOL bRotate)
{
	collected.push_back(R);
	
	LPDWORD lm	= D->lm.pSurface;
	u32	s_x	= D->lm.dwWidth+2*BORDER;
	u32	s_y = D->lm.dwHeight+2*BORDER;
	
	if (!bRotate) {
		// Normal (and fastest way)
		for (u32 y=0; y<s_y; y++)
		{
			BYTE*	P = surface+(y+R.a.y)*lmap_size+R.a.x;	// destination scan-line
			u32*	S = lm + y*s_x;
			for (u32 x=0; x<s_x; x++,P++) 
			{
				u32 C = *S++;
				u32 A = RGBA_GETALPHA	(C);
				if (A>=alpha_ref)	*P	= 255;
			}
		}
	} else {
		// Rotated :(
		for (u32 y=0; y<s_x; y++)
		{
			BYTE*	P = surface+(y+R.a.y)*lmap_size+R.a.x;	// destination scan-line
			for (u32 x=0; x<s_y; x++,P++)
			{
				u32 C = lm[x*s_x+y];
				u32 A = RGBA_GETALPHA(C);
				if (A>=alpha_ref)	*P	= 255;
			}
		}
	}
}
コード例 #2
0
ファイル: xrMergeLM.cpp プロジェクト: 2asoft/xray
// Test of per-pixel intersection (surface test)
bool Place_Perpixel(_rect& R, CDeflector* D, BOOL bRotate)
{
	LPDWORD lm			= D->lm.pSurface;
	u32	s_x			= D->lm.dwWidth	+2*BORDER;
	u32	s_y			= D->lm.dwHeight+2*BORDER;
	
	if (!bRotate) {
		// Normal (and fastest way)
		for (u32 y=0; y<s_y; y++)
		{
			BYTE*	P = surface+(y+R.a.y)*lmap_size+R.a.x;	// destination scan-line
			u32*	S = lm + y*s_x;
			for (u32 x=0; x<s_x; x++,P++) 
			{
				u32 C = *S++;
				u32 A = RGBA_GETALPHA(C);
				if ((*P)&&(A>=alpha_ref))	return false;
			}
		}
	} else {
		// Rotated :(
		for (u32 y=0; y<s_x; y++)
		{
			BYTE*	P = surface+(y+R.a.y)*lmap_size+R.a.x;	// destination scan-line
			for (u32 x=0; x<s_y; x++,P++)
			{
				u32 C = lm[x*s_x+y];
				u32 A = RGBA_GETALPHA(C);
				if ((*P)&&(A>=alpha_ref))	return false;
			}
		}
	}
	
	// It's OK to place it
	return true;
}
コード例 #3
0
ファイル: math.c プロジェクト: AmesianX/RosWine
/* Determine the alpha part of a color */
D3DVALUE WINAPI D3DRMColorGetAlpha(D3DCOLOR color)
{
    return (RGBA_GETALPHA(color)/255.0);
}
コード例 #4
0
void PaletteHandle::Load(UInt16 info, UInt16 PalBitsPerEntry, UInt16 index, UInt16 entries,UInt8 *PalBuffer)
{
	ShiAssert(m_pIDDP && entries <= m_nNumEntries);
	if(!m_pIDDP || !m_pPalData) return;

	if((DWORD *) PalBuffer != m_pPalData)
		memcpy(m_pPalData, PalBuffer, sizeof(DWORD) * entries);

	// Convert palette
	DWORD dwTmp;
	for(int i=0;i<m_nNumEntries;i++)
	{
		dwTmp = m_pPalData[i];
		m_pPalData[i] = RGBA_MAKE(RGBA_GETBLUE(dwTmp), RGBA_GETGREEN(dwTmp), RGBA_GETRED(dwTmp), RGBA_GETALPHA(dwTmp));
	}

	HRESULT hr = m_pIDDP->SetEntries(NULL, index, entries, (LPPALETTEENTRY) PalBuffer);
	ShiAssert(SUCCEEDED(hr));

	if(SUCCEEDED(hr))
	{
		// Reload attached textures
		for(int i=0;i<m_arrAttachedTextures.size();i++)
			m_arrAttachedTextures[i]->Reload();
	}
}