0

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 !

Allen Hong
  • 56
  • 4
  • [MSDN doesn't say anything](http://msdn.microsoft.com/en-us/library/windows/desktop/gg426181(v=vs.85).aspx) about the last parameter being allowed as `NULL`. Are you sure this is ok? – Roger Rowland Dec 26 '13 at 08:20
  • so , can you give me a sample value of last parameter ? – Allen Hong Dec 26 '13 at 08:39
  • Well, I'm not saying it's wrong to be NULL, otherwise I would have answered - I just compared your call to the documentation to see why it may be complaining about an invalid argument. – Roger Rowland Dec 26 '13 at 08:42
  • %>_<% , I cannot unstandard which parameter is wrong.I set a value for the last value , but it also does't work. – Allen Hong Dec 26 '13 at 08:53

1 Answers1

0

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.