2 leeonlyou leeonlyou 于 2013.10.17 17:23 提问

为什么监控画面锁屏后解锁获取不到资源出错,求解?

下列是D3D绘制图像的函数代码,没有锁屏之前监控画面好好的,锁屏之后再解锁就获取不到监控画面了,锁屏会对程序有影响吗?求指点迷津。

void ComponentBase::Draw(BYTE* data)
{
D3DLOCKED_RECT d3dRect;
g_pTexture->LockRect( 0, &d3dRect, 0, 0 );// 锁住纹理
// 填充数据
BYTE *pDst = (BYTE *)d3dRect.pBits;
//int pitch = d3dRect.Pitch >> 2;
int pitch = width;

for (int i=0; i<height; ++i)
{
    for (int j=0; j<width; ++j)
    {
        pDst[(height - i - 1) * pitch * 4 + j * 4] = data[i * pitch * 3 + j * 3];
        pDst[(height - i - 1) * pitch * 4 + j * 4 + 1] = data[i * pitch * 3 + j * 3 + 1];
        pDst[(height - i - 1) * pitch * 4 + j * 4 + 2] = data[i * pitch * 3 + j * 3 + 2];
        pDst[(height - i - 1) * pitch * 4 + j * 4 + 3] = 255;
    }
}
g_pTexture->UnlockRect (0);
RECT  rcSource;
rcSource.top = 0;
rcSource.left = 0;
rcSource.bottom = height;
rcSource.right = width;
D3DXVECTOR3 vCenter( 0.0f, 0.0f, 0.0f );
D3DXVECTOR3 vPosition( 0.0f, 0.0f, 0.0f );
g_pD3DXSprite->Begin( D3DXSPRITE_ALPHABLEND );(D3DXSPRITE_SORT_TEXTURE)
{
    g_pD3DXSprite->Draw( g_pTexture,
        &rcSource,
        &vCenter,
        &vPosition,
        D3DCOLOR_COLORVALUE(1.0f,1.0f,1.0f,1.0f) );
}
g_pD3DXSprite->End();//绘制结束

}`

Csdn user default icon
上传中...
上传图片
插入图片