如何才能够把内存中的RGB数据写到DirectDraw的surface中,并且显示出来呢?
我有段RGB数据,在内存中(没有其他的信息,比如说明bmp文件头什么的,只是RGB的raw数据),我把他写到directdraw的surface中,可是显示的是倒的数据,并且颜色好像不对,而且只有原来的一半大小,我猜只有16色...可是源是16位的...
if(FAILED(lpDDSPrimary->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL)))
{
AfxMessageBox("could not lock the primary surface");
}
pTxtBuffer = (BYTE *)ddsd.lpSurface;
for(int y = 0; y < m_lVidHeight; y++ ) {
BYTE *pBmpBufferOld = pBmpBuffer;
BYTE *pTxtBufferOld = pTxtBuffer;
for (int x = 0; x < m_lVidWidth ; x++) {
pTxtBuffer[x] = pBmpBuffer[x];
}
pBmpBuffer = pBmpBufferOld + m_lVidPitch;
pTxtBuffer = pTxtBufferOld + ddsd.lPitch;
}
if(FAILED(lpDDSPrimary->Unlock(NULL)))
{
AfxMessageBox("could not unlock the primary surface");
}