DirectDraw的Surface是32位的,我要显示24位,16位,8位BMP图,怎么办?
DirectDraw的Surface是32位的,我要显示24位,16位,8位BMP图,怎么办?怎么进行全屏播放?
我在创建主表面时,没有设置象素格式,而在创建离屏(OFFSCREENPLAIN)表面时设置了象素格式如下:
ZeroMemory( &ddsd, sizeof(ddsd) );
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = nVidWidth;
ddsd.dwHeight = nVidHeight;
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddpfPixelFormat.dwRGBBitCount = 24;
switch( nClrDepth )
{
case 8:
ddsd.ddpfPixelFormat.dwRBitMask = 0xFF0000;
break;
case 15: //RGB555
ddsd.ddpfPixelFormat.dwRBitMask = 0x7c00;
ddsd.ddpfPixelFormat.dwGBitMask = 0x3e0;
ddsd.ddpfPixelFormat.dwBBitMask = 0x1f;
break;
case 16: //RGB565
ddsd.ddpfPixelFormat.dwRBitMask = 0xf800;
ddsd.ddpfPixelFormat.dwGBitMask = 0x7e0;
ddsd.ddpfPixelFormat.dwBBitMask = 0x1f;
break;
case 24:
ddsd.ddpfPixelFormat.dwRBitMask = 0xff0000;
ddsd.ddpfPixelFormat.dwGBitMask = 0xff00;
ddsd.ddpfPixelFormat.dwBBitMask = 0xff;
break;
case 32:
ddsd.ddpfPixelFormat.dwRBitMask = 0xff0000;
ddsd.ddpfPixelFormat.dwGBitMask = 0xff00;
ddsd.ddpfPixelFormat.dwBBitMask = 0xff;
break;
default:
return FALSE;
}
ddrval = m_lpDDraw->CreateSurface( &ddsd, &m_lpddsBack, NULL );
它经常返回一个错误(象素格式不正确)