W
wanghui0415
Unregistered / Unconfirmed
GUEST, unregistred user!
小弟有点问题提问劳驾一下大家,希望得到大家的帮助。谢谢我想做一个特下,即图片叠加和融合的操作。如果比如欠两个图片叠加了,用叠加的结果和第三个混合。我的思路是把前两个叠加后,从背景中取出叠加结果。保存到一个LPDIRECT3DTEXTURE9,然后在跟第三个混合。可是我去背景拷贝到LPDIRECT3DTEXTURE9效率太高。大家有没有更好的办法。我在D3D中想或得想得到背景图片用的方法是: char * pBackBuffer = NULL;
LPDIRECT3DSURFACE9 l_BackSurface = NULL;
//获得背景存储为文件 m_pD3DDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &l_BackSurface);
D3DLOCKED_RECT d3dl_rect;
m_OffScreenSurface->LockRect(&d3dl_rect, NULL, NULL );
pBackBuffer = (char *)d3dl_rect.pBits;
// 此处就是保存背景位图的指针 D3DLOCKED_RECT stLockedRect;
m_pBackTexture->LockRect( 0, &stLockedRect, NULL, D3DLOCK_NO_DIRTY_UPDATE| D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY);
char *pch=(char *)stLockedRect.pBits;
int lpitchlen = m_BackWidth*4;
for (int i=0;i<m_BackHeight;i++) { memcpy(pch, pBackBuffer, lpitchlen);
//此处操作了背景区域的内容,为此CPU上去了 pch += stLockedRect.Pitch;
pBackBuffer += d3dl_rect.Pitch;
} m_pBackTexture->UnlockRect(0);
m_OffScreenSurface->UnlockRect();pBackBuffer这是显存数据。我一秒中执行10词这个操作,CPU在15%左右。只要对pBackBuffer操作CPU就高。按说这个操作是可以基本不占用CPUde 各位有好的办法吗?谢谢您。
LPDIRECT3DSURFACE9 l_BackSurface = NULL;
//获得背景存储为文件 m_pD3DDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &l_BackSurface);
D3DLOCKED_RECT d3dl_rect;
m_OffScreenSurface->LockRect(&d3dl_rect, NULL, NULL );
pBackBuffer = (char *)d3dl_rect.pBits;
// 此处就是保存背景位图的指针 D3DLOCKED_RECT stLockedRect;
m_pBackTexture->LockRect( 0, &stLockedRect, NULL, D3DLOCK_NO_DIRTY_UPDATE| D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY);
char *pch=(char *)stLockedRect.pBits;
int lpitchlen = m_BackWidth*4;
for (int i=0;i<m_BackHeight;i++) { memcpy(pch, pBackBuffer, lpitchlen);
//此处操作了背景区域的内容,为此CPU上去了 pch += stLockedRect.Pitch;
pBackBuffer += d3dl_rect.Pitch;
} m_pBackTexture->UnlockRect(0);
m_OffScreenSurface->UnlockRect();pBackBuffer这是显存数据。我一秒中执行10词这个操作,CPU在15%左右。只要对pBackBuffer操作CPU就高。按说这个操作是可以基本不占用CPUde 各位有好的办法吗?谢谢您。