Step1:
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 );
}
}
Step2:
RECT SrcRect={0,0,fTexWidth,fTexHeight}; RECT DstRect = {0,0,60,20};
hr = m_pPrimarySurf->Blt(&DstRect,
m_pFPSTexture,&SrcRect,DDBLT_WAIT,NULL);
Note: The image size is : 3170 x 64
m_pPrimarySurf->Blt(...) returned E_INVALIDARG . So why ? Thx !
Happened to me too. I fixed it by changing driver type. When I created DirectDraw object, I specified that software only rendering should be used.
LPDIRECTDRAW dd; HRESULT const dd_created = DirectDrawCreate(reinterpret_cast<GUID*>(DDCREATE_EMULATIONONLY), &dd, nullptr);
as stated in DirectDrawCreate function documentation on MSDN. I'm running x86 application on Windows 10 x64 version 10.0.18363.1082, inside VirtualBox 5.2.42_Ubuntu r137960 inside Ubuntu x64 18.04.5 LTS on Lenovo laptop with Intel® UHD Graphics 620 (WHL GT2) graphics.