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();
	}
}
Example #2
0
HBITMAP TgaLoad (unsigned char *pauchData)
{

	//
	// Load the image
	//

	int nWidth, nHeight;
	D3DCOLOR *pData = TgaLoad (pauchData, &nWidth, &nHeight);
	if (pData == NULL)
		return NULL;

	//
	// Initialize a DIB
	//

	BITMAPINFOHEADER BMI;
	BMI .biSize = sizeof (BITMAPINFOHEADER);
	BMI .biWidth = nWidth;
	BMI .biHeight = nHeight;
	BMI .biPlanes = 1;
	BMI .biBitCount = 32;
	BMI .biCompression = BI_RGB;
	BMI .biSizeImage = 0;
	BMI .biXPelsPerMeter = 0;
	BMI .biYPelsPerMeter = 0;
	BMI .biClrUsed = 0;
	BMI .biClrImportant = 0;
	
	//
	// Create DIB section in shared memory
	//

	COLORREF *pDstBits;
	CClientDC dc (::GetDesktopWindow ());
	HBITMAP hbm = ::CreateDIBSection (dc, (BITMAPINFO *)&BMI,
		DIB_RGB_COLORS, (void **) &pDstBits, 0, 0l);
	if (hbm == NULL)
		return NULL;

	//
	// Convert 
	//

	for (int i = 0; i < nWidth * nHeight; i++)
	{
		pDstBits [i] = RGB (
			RGBA_GETRED (pData [i]),
			RGBA_GETGREEN (pData [i]),
			RGBA_GETBLUE (pData [i]));
	}
	delete [] pData;
	return hbm;
}
Example #3
0
/* Determine the blue part of a color */
D3DVALUE WINAPI D3DRMColorGetBlue(D3DCOLOR color)
{
    return (RGBA_GETBLUE(color)/255.0);
}