IDirectDrawSurface7 :: Blt返回E_INVALIDARG

时间:2013-12-26 08:07:20

标签: c++ directdraw

步骤1:

                Image* image = NULL;
                image = Bitmap::FromFile(m_lpwFPSImagePath[i], TRUE);

                DDSURFACEDESC2    ddsd;
                DDCOLORKEY          ddck;
                ZeroMemory( &ddsd, sizeof( ddsd ) );
                ddsd.dwSize = sizeof( ddsd );
                ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
                ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
                ddsd.dwWidth  = image->GetWidth();;
                ddsd.dwHeight = image->GetHeight();
                hr = m_pDevice->CreateSurface(&ddsd, &m_pFPSTexture, NULL );
                if( hr != DD_OK )
                {
                    if(hr == DDERR_OUTOFVIDEOMEMORY)
                    {
                        ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN |
                            DDSCAPS_SYSTEMMEMORY;
                        hr = m_pDevice->CreateSurface(&ddsd, &m_pFPSTexture, NULL );
                    }
                }

步骤2:

RECT SrcRect = {0,0,fTexWidth,fTexHeight};         RECT DstRect = {0,0,60,20};

    hr = m_pPrimarySurf->Blt(&DstRect,
        m_pFPSTexture,&SrcRect,DDBLT_WAIT,NULL);

注意: 图像大小为:3170 x 64

m_pPrimarySurf-> Blt(...)返回E_INVALIDARG。所以为什么 ? 谢谢!

1 个答案:

答案 0 :(得分:0)

也发生在我身上。我通过更改驱动程序类型来修复它。创建DirectDraw对象时,我指定应仅使用软件渲染。 MSDN上DirectDrawCreate function文档中所述的LPDIRECTDRAW dd; HRESULT const dd_created = DirectDrawCreate(reinterpret_cast<GUID*>(DDCREATE_EMULATIONONLY), &dd, nullptr);。我正在具有英特尔®UHD Graphics 620(WHL GT2)图形的联想笔记本电脑上的Windows 10 x64版本10.0.18363.1082,VirtualBox 5.2.42_Ubuntu r137960和Ubuntu x64 18.04.5 LTS内运行x86应用程序。