我的没有灰度等级,bpp就是1啊。
ULONG BitMasks[][3] =
{
{ 0, 0, 0 },
{ 0xF800, 0x07E0, 0x001F },
{ 0xFF0000, 0x00FF00, 0x0000FF },
{ 0x00FF0000, 0x0000FF00, 0x000000FF }
};
SCODE S3C2440DISP::SetMode (INT modeId, HPALETTE *palette)
{
// jylee
RETAILMSG(DBGLCD, (TEXT("++S3C2440DISP::SetMode\r\n")));
if (modeId != 0)
{
RETAILMSG(1, (TEXT("S3C2440DISP::SetMode Want mode %d, only have mode 0\r\n"),modeId));
return E_INVALIDARG;
}
if (palette)
{
RETAILMSG(DBGLCD, (TEXT("Calling EngCreatePalette\r\n")));
// *palette = ourengineCallbacks->EngCreatePalette(PAL_BITFIELDS, 0, NULL, gBitMasks[0], gBitMasks[1], gBitMasks[2]);
int nBPP = m_pMode->Bpp/8 - 1;
switch (m_pMode->Bpp)
{
//case 8:
case 16:
case 24:
case 32:
*palette = ourengineCallbacks->EngCreatePalette (PAL_BITFIELDS,
0,
NULL,
BitMasks[nBPP][0],
BitMasks[nBPP][1],
BitMasks[nBPP][2]);
break;
default :
RETAILMSG(1, (TEXT("ERR !!! S3C2440DISP::SetMode , m_pMode->Bpp = %d \r\n"),m_pMode->Bpp));
}
// This sets the surface address alignment
m_nSurfaceBitsAlign = (m_pMode->Bpp == 24) ? (128 * 3) : 128;
//Allocate our primary surface here
if(NULL == m_pPrimarySurface)
{
if(FAILED(AllocSurface((DDGPESurf **)&m_pPrimarySurface, m_nScreenWidth,
m_nScreenHeight, m_pMode->format, m_pModeEx->ePixelFormat,
GPE_REQUIRE_VIDEO_MEMORY)))
{
RETAILMSG (1, (L"Couldn't allocate primary surface\n"));
return E_INVALIDARG;
}
}
m_pPrimarySurface->SetRotation(m_nScreenWidth, m_nScreenHeight, m_iRotate);
}
DynRotate(m_iRotate);
RETAILMSG(DBGLCD, (TEXT("--S3C2440DISP::SetMode\r\n")));
return S_OK;
}